From c8a106f485ff7e340ee8ca67adac3351ec6a31b6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 12 Jan 2014 01:31:21 -0500 Subject: move media encoder to server project --- MediaBrowser.Controller/Entities/Audio/Audio.cs | 2 +- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 3 +- .../MediaBrowser.Controller.csproj | 2 + MediaBrowser.Controller/MediaInfo/FFMpegManager.cs | 3 +- MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs | 106 +++++++ .../MediaInfo/InternalMediaInfoResult.cs | 311 +++++++++++++++++++++ .../MediaInfo/MediaEncoderHelpers.cs | 21 +- 7 files changed, 437 insertions(+), 11 deletions(-) create mode 100644 MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs create mode 100644 MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 028fc964d..9e4129cd1 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -109,7 +109,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// System.String. public override string GetUserDataKey() { - var parent = Parent as MusicAlbum; + var parent = FindParent(); if (parent != null) { diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index d23c8c555..1856182da 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -1,5 +1,4 @@ -using System.IO; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; using System.Collections.Generic; diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 61de32e41..9082186fd 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -125,6 +125,8 @@ + + diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs index 644222949..c1951038c 100644 --- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs +++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; -using MediaBrowser.Common.MediaInfo; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; @@ -178,7 +177,7 @@ namespace MediaBrowser.Controller.MediaInfo Directory.CreateDirectory(parentPath); - await _encoder.ExtractImage(inputPath, type, video.Video3DFormat, time, path, cancellationToken).ConfigureAwait(false); + await _encoder.ExtractImage(inputPath, type, false, video.Video3DFormat, time, path, cancellationToken).ConfigureAwait(false); chapter.ImagePath = path; changesMade = true; } diff --git a/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs b/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs new file mode 100644 index 000000000..8e0d696c9 --- /dev/null +++ b/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs @@ -0,0 +1,106 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Controller.MediaInfo +{ + /// + /// Interface IMediaEncoder + /// + public interface IMediaEncoder + { + /// + /// Gets the encoder path. + /// + /// The encoder path. + string EncoderPath { get; } + + /// + /// Gets the version. + /// + /// The version. + string Version { get; } + + /// + /// Extracts the image. + /// + /// The input files. + /// The type. + /// if set to true [is audio]. + /// The threed format. + /// The offset. + /// The output path. + /// The cancellation token. + /// Task. + Task ExtractImage(string[] inputFiles, InputType type, bool isAudio, Video3DFormat? threedFormat, TimeSpan? offset, string outputPath, CancellationToken cancellationToken); + + /// + /// Extracts the text subtitle. + /// + /// The input files. + /// The type. + /// Index of the subtitle stream. + /// The output path. + /// The cancellation token. + /// Task. + Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, string outputPath, CancellationToken cancellationToken); + + /// + /// Converts the text subtitle to ass. + /// + /// The input path. + /// The output path. + /// The language. + /// The cancellation token. + /// Task. + Task ConvertTextSubtitleToAss(string inputPath, string outputPath, string language, CancellationToken cancellationToken); + + /// + /// Gets the media info. + /// + /// The input files. + /// The type. + /// The cancellation token. + /// Task. + Task GetMediaInfo(string[] inputFiles, InputType type, CancellationToken cancellationToken); + + /// + /// Gets the probe size argument. + /// + /// The type. + /// System.String. + string GetProbeSizeArgument(InputType type); + + /// + /// Gets the input argument. + /// + /// The input files. + /// The type. + /// System.String. + string GetInputArgument(string[] inputFiles, InputType type); + } + + /// + /// Enum InputType + /// + public enum InputType + { + /// + /// The file + /// + File, + /// + /// The bluray + /// + Bluray, + /// + /// The DVD + /// + Dvd, + /// + /// The URL + /// + Url + } +} diff --git a/MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs b/MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs new file mode 100644 index 000000000..3ceec1b90 --- /dev/null +++ b/MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs @@ -0,0 +1,311 @@ +using System.Collections.Generic; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Controller.MediaInfo +{ + /// + /// Class MediaInfoResult + /// + public class InternalMediaInfoResult + { + /// + /// Gets or sets the streams. + /// + /// The streams. + public MediaStreamInfo[] streams { get; set; } + + /// + /// Gets or sets the format. + /// + /// The format. + public MediaFormatInfo format { get; set; } + + /// + /// Gets or sets the chapters. + /// + /// The chapters. + public List Chapters { get; set; } + } + + /// + /// Represents a stream within the output + /// + public class MediaStreamInfo + { + /// + /// Gets or sets the index. + /// + /// The index. + public int index { get; set; } + + /// + /// Gets or sets the profile. + /// + /// The profile. + public string profile { get; set; } + + /// + /// Gets or sets the codec_name. + /// + /// The codec_name. + public string codec_name { get; set; } + + /// + /// Gets or sets the codec_long_name. + /// + /// The codec_long_name. + public string codec_long_name { get; set; } + + /// + /// Gets or sets the codec_type. + /// + /// The codec_type. + public string codec_type { get; set; } + + /// + /// Gets or sets the sample_rate. + /// + /// The sample_rate. + public string sample_rate { get; set; } + + /// + /// Gets or sets the channels. + /// + /// The channels. + public int channels { get; set; } + + /// + /// Gets or sets the channel_layout. + /// + /// The channel_layout. + public string channel_layout { get; set; } + + /// + /// Gets or sets the avg_frame_rate. + /// + /// The avg_frame_rate. + public string avg_frame_rate { get; set; } + + /// + /// Gets or sets the duration. + /// + /// The duration. + public string duration { get; set; } + + /// + /// Gets or sets the bit_rate. + /// + /// The bit_rate. + public string bit_rate { get; set; } + + /// + /// Gets or sets the width. + /// + /// The width. + public int width { get; set; } + + /// + /// Gets or sets the height. + /// + /// The height. + public int height { get; set; } + + /// + /// Gets or sets the display_aspect_ratio. + /// + /// The display_aspect_ratio. + public string display_aspect_ratio { get; set; } + + /// + /// Gets or sets the tags. + /// + /// The tags. + public Dictionary tags { get; set; } + + /// + /// Gets or sets the bits_per_sample. + /// + /// The bits_per_sample. + public int bits_per_sample { get; set; } + + /// + /// Gets or sets the r_frame_rate. + /// + /// The r_frame_rate. + public string r_frame_rate { get; set; } + + /// + /// Gets or sets the has_b_frames. + /// + /// The has_b_frames. + public int has_b_frames { get; set; } + + /// + /// Gets or sets the sample_aspect_ratio. + /// + /// The sample_aspect_ratio. + public string sample_aspect_ratio { get; set; } + + /// + /// Gets or sets the pix_fmt. + /// + /// The pix_fmt. + public string pix_fmt { get; set; } + + /// + /// Gets or sets the level. + /// + /// The level. + public int level { get; set; } + + /// + /// Gets or sets the time_base. + /// + /// The time_base. + public string time_base { get; set; } + + /// + /// Gets or sets the start_time. + /// + /// The start_time. + public string start_time { get; set; } + + /// + /// Gets or sets the codec_time_base. + /// + /// The codec_time_base. + public string codec_time_base { get; set; } + + /// + /// Gets or sets the codec_tag. + /// + /// The codec_tag. + public string codec_tag { get; set; } + + /// + /// Gets or sets the codec_tag_string. + /// + /// The codec_tag_string. + public string codec_tag_string { get; set; } + + /// + /// Gets or sets the sample_fmt. + /// + /// The sample_fmt. + public string sample_fmt { get; set; } + + /// + /// Gets or sets the dmix_mode. + /// + /// The dmix_mode. + public string dmix_mode { get; set; } + + /// + /// Gets or sets the start_pts. + /// + /// The start_pts. + public string start_pts { get; set; } + + /// + /// Gets or sets the is_avc. + /// + /// The is_avc. + public string is_avc { get; set; } + + /// + /// Gets or sets the nal_length_size. + /// + /// The nal_length_size. + public string nal_length_size { get; set; } + + /// + /// Gets or sets the ltrt_cmixlev. + /// + /// The ltrt_cmixlev. + public string ltrt_cmixlev { get; set; } + + /// + /// Gets or sets the ltrt_surmixlev. + /// + /// The ltrt_surmixlev. + public string ltrt_surmixlev { get; set; } + + /// + /// Gets or sets the loro_cmixlev. + /// + /// The loro_cmixlev. + public string loro_cmixlev { get; set; } + + /// + /// Gets or sets the loro_surmixlev. + /// + /// The loro_surmixlev. + public string loro_surmixlev { get; set; } + + /// + /// Gets or sets the disposition. + /// + /// The disposition. + public Dictionary disposition { get; set; } + } + + /// + /// Class MediaFormat + /// + public class MediaFormatInfo + { + /// + /// Gets or sets the filename. + /// + /// The filename. + public string filename { get; set; } + + /// + /// Gets or sets the nb_streams. + /// + /// The nb_streams. + public int nb_streams { get; set; } + + /// + /// Gets or sets the format_name. + /// + /// The format_name. + public string format_name { get; set; } + + /// + /// Gets or sets the format_long_name. + /// + /// The format_long_name. + public string format_long_name { get; set; } + + /// + /// Gets or sets the start_time. + /// + /// The start_time. + public string start_time { get; set; } + + /// + /// Gets or sets the duration. + /// + /// The duration. + public string duration { get; set; } + + /// + /// Gets or sets the size. + /// + /// The size. + public string size { get; set; } + + /// + /// Gets or sets the bit_rate. + /// + /// The bit_rate. + public string bit_rate { get; set; } + + /// + /// Gets or sets the tags. + /// + /// The tags. + public Dictionary tags { get; set; } + } +} diff --git a/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs index 261454f6d..300071b7b 100644 --- a/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs +++ b/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using MediaBrowser.Common.MediaInfo; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; @@ -29,7 +28,7 @@ namespace MediaBrowser.Controller.MediaInfo { var inputPath = isoMount == null ? new[] { videoPath } : new[] { isoMount.MountedPath }; - type = InputType.VideoFile; + type = InputType.File; switch (videoType) { @@ -87,7 +86,7 @@ namespace MediaBrowser.Controller.MediaInfo /// InputType. public static InputType GetInputType(VideoType? videoType, IsoType? isoType) { - var type = InputType.AudioFile; + var type = InputType.File; if (videoType.HasValue) { @@ -119,12 +118,22 @@ namespace MediaBrowser.Controller.MediaInfo return type; } - public static IEnumerable GetMediaStreams(MediaInfoResult data) + public static Model.Entities.MediaInfo GetMediaInfo(InternalMediaInfoResult data) { var internalStreams = data.streams ?? new MediaStreamInfo[] { }; - return internalStreams.Select(s => GetMediaStream(s, data.format)) - .Where(i => i != null); + var info = new Model.Entities.MediaInfo(); + + info.MediaStreams = internalStreams.Select(s => GetMediaStream(s, data.format)) + .Where(i => i != null) + .ToList(); + + if (data.format != null) + { + info.Format = data.format.format_name; + } + + return info; } private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); -- cgit v1.2.3