diff options
| author | dkanada <dkanada@users.noreply.github.com> | 2020-01-08 11:04:21 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-08 11:04:21 +0900 |
| commit | 423d50e9785e6c97b566059abcb51e7d6e3d99f0 (patch) | |
| tree | 7d671066170ba6632dc38aa11cfe98ae5514dcb1 /MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs | |
| parent | 534716d9c90fd0691dcbe3ec5a3fdf8ac265cbb1 (diff) | |
| parent | 73fac50e57982ac46aea2b487e9906826c3dc3b2 (diff) | |
Merge pull request #1838 from Unhelpful/media-attachments
Add support for embedded attachments in media files
Diffstat (limited to 'MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index ff3596a85..a46aa38d8 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -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); @@ -514,6 +518,39 @@ namespace MediaBrowser.MediaEncoding.Probing } /// <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> /// <param name="isAudio">if set to <c>true</c> [is info].</param> |
