stride3d/stride · error · ApplicationException

Could not find stream info.

Error message

Could not find stream info.

What it means

FFmpegMedia.Open throws this ApplicationException when ffmpeg.avformat_find_stream_info returns a negative code, i.e. the container was opened but FFmpeg could not determine stream information (codecs, durations, parameters). Hex code and av_strerror details are logged before the throw.

Solutions

  1. Inspect the logged hex error code and av_strerror message for the precise cause.
  2. Verify the file plays in ffprobe/ffmpeg to rule out corruption or unsupported codecs.
  3. For network streams, increase probe limits (probesize/analyzeduration) or check network availability.
  4. Use a complete FFmpeg build that includes decoders for the stream's codecs.

Example fix

// before
formatContext->probesize = 5000; // too small, stream info probing fails
// after
formatContext->probesize = 5000000;
formatContext->max_analyze_duration = 10 * ffmpeg.AV_TIME_BASE;
ret = ffmpeg.avformat_find_stream_info(pFormatContext, null);
Defensive patterns

Strategy: retry

Validate before calling

// pre-check with ffprobe-style metadata or ensure the file size is complete
var fi = new FileInfo(path);
if (fi.Length == 0 || !downloadComplete) throw new InvalidDataException("Incomplete media file");

Try / catch

try
{
    media.Open(url, startPosition, length);
}
catch (ApplicationException ex) when (ex.Message == "Could not find stream info.")
{
    // check logs for hex code; retry once or mark media as unsupported/corrupt
}

Prevention

When it happens

Trigger: Calling Open on a file whose container opens successfully but whose streams cannot be probed: truncated/corrupt files, missing codecs in the FFmpeg build, network streams that time out during probing, or headers without enough metadata.

Common situations: Partially downloaded or corrupted media files; exotic codecs not compiled into the bundled FFmpeg binaries; slow/unreliable network streams exceeding FFmpeg's probe limits; streams with missing or wrong codec extradata.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Video/FFmpeg/FFmpegMedia.cs:145

            if (startPosition != 0 && length != -1)
                url = $@"subfile,,start,{startPosition},end,{startPosition + length},,:{url}";

            var pFormatContext = ffmpeg.avformat_alloc_context();
            var ret = ffmpeg.avformat_open_input(&pFormatContext, url, null, null);
            if (ret < 0)
            {
                Logger.Error($"Could not open file. Error code={ret.ToString("X8")}");
                Logger.Error(GetErrorMessage(ret));
                throw new ApplicationException(@"Could not open file.");
            }

            ret = ffmpeg.avformat_find_stream_info(pFormatContext, null);
            if (ret < 0)
            {
                Logger.Error($"Could not find stream info. Error code={ret.ToString("X8")}");
                Logger.Error(GetErrorMessage(ret));
                throw new ApplicationException(@"Could not find stream info.");
            }

            AVFormatContext = pFormatContext;
            Duration = TimeSpan.FromSeconds((double)AVFormatContext->duration / ffmpeg.AV_TIME_BASE);
            Url = url;

            // Get the streams
            for (int i = 0; i < pFormatContext->nb_streams; i++)
            {
                var stream = FFmpegStream.Create(pFormatContext->streams[i], this);
                streams.Add(stream);
            }

            pDecodedFrame = ffmpeg.av_frame_alloc();
            if (pDecodedFrame == null)
                throw new ApplicationException("Couldn't allocate a frame for decoding.");

            pCpuCopyFrame = ffmpeg.av_frame_alloc();

View on GitHub (pinned to 96fad776d2)