jellyfin/jellyfin · error · ResourceNotFoundException
Attachment with stream index {attachmentStreamIndex} can't b
Error message
Attachment with stream index {attachmentStreamIndex} can't be extracted for MediaSource {mediaSourceId} What it means
An intentional extraction refusal: the matched attachment's Codec is 'mjpeg' (case-insensitive). MJPEG 'attachments' are embedded cover/cover-image frames, not the font files attachment extraction is built for, so ffmpeg cannot pull them out as a normal attachment. Treated as ResourceNotFoundException (404) so clients treat it as 'not extractable'.
Source
Thrown at MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs:89
var mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false);
var mediaSource = mediaSources
.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
if (mediaSource is null)
{
throw new ResourceNotFoundException($"MediaSource {mediaSourceId} not found");
}
var mediaAttachment = mediaSource.MediaAttachments
.FirstOrDefault(i => i.Index == attachmentStreamIndex);
if (mediaAttachment is null)
{
throw new ResourceNotFoundException($"MediaSource {mediaSourceId} has no attachment with stream index {attachmentStreamIndex}");
}
if (string.Equals(mediaAttachment.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
{
throw new ResourceNotFoundException($"Attachment with stream index {attachmentStreamIndex} can't be extracted for MediaSource {mediaSourceId}");
}
var attachmentStream = await GetAttachmentStream(mediaSource, mediaAttachment, cancellationToken)
.ConfigureAwait(false);
return (mediaAttachment, attachmentStream);
}
/// <inheritdoc />
public async Task ExtractAllAttachments(
string inputFile,
MediaSourceInfo mediaSource,
CancellationToken cancellationToken)
{
var shouldExtractOneByOne = mediaSource.MediaAttachments.Any(a => !string.IsNullOrEmpty(a.FileName)
&& !string.Equals(PathHelper.GetSafeLeafFileName(a.FileName), a.FileName, StringComparison.Ordinal));
if (shouldExtractOneByOne && !inputFile.EndsWith(".mks", StringComparison.OrdinalIgnoreCase))
{View on GitHub (pinned to ae8723026d)
Solutions
- Skip attachments whose codec is mjpeg when listing extractable attachments.
- Use the cover-art/image endpoint instead of the attachment endpoint for embedded MJPEG art.
- Filter client-side before issuing the extraction request.
Example fix
// before
var attachment = mediaSource.MediaAttachments.First(a => a.Index == idx);
// after: skip non-extractable MJPEG art
var attachment = mediaSource.MediaAttachments
.FirstOrDefault(a => a.Index == idx
&& !string.Equals(a.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)); Defensive patterns
Strategy: validation
Validate before calling
// Skip MJPEG attachments (embedded cover art) before extracting.
if (string.Equals(attach.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
{
return NotFound("MJPEG attachments are not extractable; use the cover-art endpoint.");
} Type guard
static bool IsExtractableAttachment(MediaAttachment a) =>
!string.Equals(a.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase); Try / catch
try { /* extract */ }
catch (ResourceNotFoundException ex) when (ex.Message.Contains("can't be extracted"))
{
return NotFound("Attachment is MJPEG cover art and cannot be extracted.");
} Prevention
- Filter MJPEG attachments out of any 'extract all attachments' loop.
- Use the image/cover-art endpoint for embedded MJPEG art.
- Document that MJPEG attachments are intentionally non-extractable.
When it happens
Trigger: mediaAttachment is found and string.Equals(mediaAttachment.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase) is true.
Common situations: A media file stores its cover art as an MJPEG attachment; the client blindly tries to extract every listed attachment; metadata reports an attachment whose codec is mjpeg.
Related errors
- MediaSource {mediaSourceId} not found
- MediaSource {mediaSourceId} has no attachment with stream in
- Failed to find an appropriate file extension
- MediaSource {mediaSource.Id} has no attachment cache (non-GU
- ffprobe failed - streams and format are both null.
AI-assisted analysis of jellyfin/jellyfin@ae8723026d (2026-08-13).
Data as JSON: /api/errors/295b5341a5b52e1f.
Report an issue: GitHub.