hcengineering/platform · error

No video stream found in metadata

Error message

No video stream found in metadata

What it means

parseMetadata inspects ffprobe/probe metadata and requires at least one stream with codec_type === 'video'. If the streams array is empty or contains only audio/subtitle streams, it throws 'No video stream found in metadata'.

Source

Thrown at pods/preview/src/metadata/video.ts:104

      if (code !== 0) {
        reject(new Error(`ffmpeg exited with code ${code}: ${error}`))
      } else {
        resolve()
      }
    })

    ffmpeg.on('error', (err) => {
      reject(new Error(`Failed to start ffmpeg: ${err.message}`))
    })
  })
}

function parseMetadata (metadata: any): VideoMetadata {
  const streams: any[] = metadata.streams ?? []
  const videoStream = streams.find((s) => s.codec_type === 'video')

  if (videoStream === undefined) {
    throw new Error('No video stream found in metadata')
  }

  return {
    duration: parseFloat(metadata.format.duration),
    width: videoStream.width,
    height: videoStream.height
  }
}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Validate the uploaded file is actually a video (extension + container check) before calling extractMetadata
  2. Reject or route audio/non-media files to an appropriate handler instead of the video preview pipeline
  3. Verify the source file is not truncated/corrupt by running ffprobe manually on it
  4. Ensure ffmpeg/ffprobe builds support the input codec (add codecs or re-encode)

Example fix

// before
const meta = await extractMetadata(ctx, file)
// after
if (await isVideoFile(file)) {
  const meta = await extractMetadata(ctx, file)
} else {
  throw new HttpError(415, 'Unsupported media type: not a video')
}
Defensive patterns

Strategy: try-catch

Validate before calling

const streams = metadata?.streams ?? []
if (!streams.some((s: any) => s.codec_type === 'video')) {
  // route to audio/unsupported handler instead of video preview
}

Type guard

function hasVideoStream (metadata: unknown): metadata is { streams: { codec_type: 'video', width: number, height: number }[]; format: { duration: string } } {
  const m = metadata as any
  return m != null && Array.isArray(m.streams) && m.streams.some((s: any) => s?.codec_type === 'video')
}

Try / catch

try {
  const meta = await extractMetadata(ctx, file)
} catch (err) {
  if (err.message === 'No video stream found in metadata') {
    return respond415('File is not a supported video')
  }
  throw err
}

Prevention

When it happens

Trigger: extractMetadata on a file whose probe output has metadata.streams missing, empty, or without any entry where codec_type === 'video' — e.g. probing an MP3 or a corrupted/unsupported container.

Common situations: Users upload audio files or unsupported formats renamed to a video extension; corrupted or zero-byte files; container ffprobe cannot fully parse; codecs the bundled ffmpeg build doesn't recognize.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/861ed80dea014a89. Report an issue: GitHub.