Add new MediaAttachment to store attachments found during media probing.

This commit is contained in:
Andrew Mahone 2019-10-03 11:51:28 -04:00
parent 91600b1c81
commit 321e5cba60
3 changed files with 84 additions and 0 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,40 @@ 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
};
// Filter out junk
if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string) && streamInfo.codec_tag_string.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1)
{
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>

View File

@ -57,6 +57,8 @@ namespace MediaBrowser.Model.Dto
public List<MediaStream> MediaStreams { get; set; }
public List<MediaAttachment> MediaAttachments { get; set; }
public string[] Formats { get; set; }
public int? Bitrate { get; set; }

View File

@ -0,0 +1,44 @@
namespace MediaBrowser.Model.Entities
{
/// <summary>
/// Class MediaAttachment
/// </summary>
public class MediaAttachment
{
/// <summary>
/// Gets or sets the codec.
/// </summary>
/// <value>The codec.</value>
public string Codec { get; set; }
/// <summary>
/// Gets or sets the codec tag.
/// </summary>
/// <value>The codec tag.</value>
public string CodecTag { get; set; }
/// <summary>
/// Gets or sets the comment.
/// </summary>
/// <value>The comment.</value>
public string Comment { get; set; }
/// <summary>
/// Gets or sets the index.
/// </summary>
/// <value>The index.</value>
public int Index { get; set; }
/// <summary>
/// Gets or sets the filename.
/// </summary>
/// <value>The filename.</value>
public string Filename { get; set; }
/// <summary>
/// Gets or sets the MIME type.
/// </summary>
/// <value>The MIME type.</value>
public string MIMEType { get; set; }
}
}