Merge pull request #1838 from Unhelpful/media-attachments

Add support for embedded attachments in media files
This commit is contained in:
dkanada
2020-01-08 11:04:21 +09:00
committed by GitHub
17 changed files with 735 additions and 7 deletions

View File

@@ -49,6 +49,10 @@ namespace MediaBrowser.MediaEncoding.Probing
.Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec))
.ToList();
info.MediaAttachments = internalStreams.Select(s => GetMediaAttachment(s))
.Where(i => i != null)
.ToList();
if (data.format != null)
{
info.Container = NormalizeFormat(data.format.format_name);
@@ -513,6 +517,39 @@ namespace MediaBrowser.MediaEncoding.Probing
return codec;
}
/// <summary>
/// Converts ffprobe stream info to our MediaAttachment class
/// </summary>
/// <param name="streamInfo">The stream info.</param>
/// <returns>MediaAttachments.</returns>
private MediaAttachment GetMediaAttachment(MediaStreamInfo streamInfo)
{
if (!string.Equals(streamInfo.codec_type, "attachment", StringComparison.OrdinalIgnoreCase))
{
return null;
}
var attachment = new MediaAttachment
{
Codec = streamInfo.codec_name,
Index = streamInfo.index
};
if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string))
{
attachment.CodecTag = streamInfo.codec_tag_string;
}
if (streamInfo.tags != null)
{
attachment.FileName = GetDictionaryValue(streamInfo.tags, "filename");
attachment.MimeType = GetDictionaryValue(streamInfo.tags, "mimetype");
attachment.Comment = GetDictionaryValue(streamInfo.tags, "comment");
}
return attachment;
}
/// <summary>
/// Converts ffprobe stream info to our MediaStream class
/// </summary>