Merge pull request #2026 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-08-05 02:13:50 -04:00 committed by GitHub
commit f326e73ab1
12 changed files with 170 additions and 70 deletions

View File

@ -286,28 +286,41 @@ namespace MediaBrowser.Api.Playback
protected string GetH264Encoder(StreamState state)
{
var defaultEncoder = "libx264";
// Only use alternative encoders for video files.
// When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully
// Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this.
if (state.VideoType == VideoType.VideoFile)
{
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase) ||
string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "h264_qsv", StringComparison.OrdinalIgnoreCase))
var hwType = ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType;
if (string.Equals(hwType, "qsv", StringComparison.OrdinalIgnoreCase) ||
string.Equals(hwType, "h264_qsv", StringComparison.OrdinalIgnoreCase))
{
return "h264_qsv";
return GetAvailableEncoder("h264_qsv", defaultEncoder);
}
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "nvenc", StringComparison.OrdinalIgnoreCase))
if (string.Equals(hwType, "nvenc", StringComparison.OrdinalIgnoreCase))
{
return "h264_nvenc";
return GetAvailableEncoder("h264_nvenc", defaultEncoder);
}
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "h264_omx", StringComparison.OrdinalIgnoreCase))
if (string.Equals(hwType, "h264_omx", StringComparison.OrdinalIgnoreCase))
{
return "h264_omx";
return GetAvailableEncoder("h264_omx", defaultEncoder);
}
}
return "libx264";
return defaultEncoder;
}
private string GetAvailableEncoder(string preferredEncoder, string defaultEncoder)
{
if (MediaEncoder.SupportsEncoder(preferredEncoder))
{
return preferredEncoder;
}
return defaultEncoder;
}
/// <summary>

View File

@ -80,7 +80,10 @@ namespace MediaBrowser.Api.Playback
{
return 10;
}
if (userAgent.IndexOf("cfnetwork", StringComparison.OrdinalIgnoreCase) != -1)
if (userAgent.IndexOf("cfnetwork", StringComparison.OrdinalIgnoreCase) != -1 ||
userAgent.IndexOf("ipad", StringComparison.OrdinalIgnoreCase) != -1 ||
userAgent.IndexOf("iphone", StringComparison.OrdinalIgnoreCase) != -1 ||
userAgent.IndexOf("ipod", StringComparison.OrdinalIgnoreCase) != -1)
{
return 10;
}

View File

@ -133,5 +133,6 @@ namespace MediaBrowser.Controller.MediaEncoding
Task Init();
Task UpdateEncoderPath(string path, string pathType);
bool SupportsEncoder(string encoder);
}
}

View File

@ -86,6 +86,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
"srt",
"h264_nvenc",
"h264_qsv",
"h264_omx",
"ac3"
};

View File

@ -522,10 +522,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
/// <summary>
/// Gets the name of the output video codec
/// </summary>
/// <param name="state">The state.</param>
/// <param name="options">The options.</param>
/// <returns>System.String.</returns>
internal static string GetVideoEncoder(EncodingJob state, EncodingOptions options)
internal static string GetVideoEncoder(IMediaEncoder mediaEncoder, EncodingJob state, EncodingOptions options)
{
var codec = state.OutputVideoCodec;
@ -533,7 +531,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
{
return GetH264Encoder(state, options);
return GetH264Encoder(mediaEncoder, state, options);
}
if (string.Equals(codec, "vpx", StringComparison.OrdinalIgnoreCase))
{
@ -554,24 +552,43 @@ namespace MediaBrowser.MediaEncoding.Encoder
return "copy";
}
internal static string GetH264Encoder(EncodingJob state, EncodingOptions options)
private static string GetAvailableEncoder(IMediaEncoder mediaEncoder, string preferredEncoder, string defaultEncoder)
{
if (string.Equals(options.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase) ||
string.Equals(options.HardwareAccelerationType, "h264_qsv", StringComparison.OrdinalIgnoreCase))
if (mediaEncoder.SupportsEncoder(preferredEncoder))
{
return "h264_qsv";
return preferredEncoder;
}
return defaultEncoder;
}
internal static string GetH264Encoder(IMediaEncoder mediaEncoder, EncodingJob state, EncodingOptions options)
{
var defaultEncoder = "libx264";
// Only use alternative encoders for video files.
// When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully
// Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this.
if (state.VideoType == VideoType.VideoFile)
{
var hwType = options.HardwareAccelerationType;
if (string.Equals(hwType, "qsv", StringComparison.OrdinalIgnoreCase) ||
string.Equals(hwType, "h264_qsv", StringComparison.OrdinalIgnoreCase))
{
return GetAvailableEncoder(mediaEncoder, "h264_qsv", defaultEncoder);
}
if (string.Equals(hwType, "nvenc", StringComparison.OrdinalIgnoreCase))
{
return GetAvailableEncoder(mediaEncoder, "h264_nvenc", defaultEncoder);
}
if (string.Equals(hwType, "h264_omx", StringComparison.OrdinalIgnoreCase))
{
return GetAvailableEncoder(mediaEncoder, "h264_omx", defaultEncoder);
}
}
if (string.Equals(options.HardwareAccelerationType, "nvenc", StringComparison.OrdinalIgnoreCase))
{
return "h264_nvenc";
}
if (string.Equals(options.HardwareAccelerationType, "h264_omx", StringComparison.OrdinalIgnoreCase))
{
return "h264_omx";
}
return "libx264";
return defaultEncoder;
}
internal static bool CanStreamCopyVideo(EncodingJobOptions request, MediaStream videoStream)

View File

@ -392,9 +392,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
//_logger.Info("Supported decoders: {0}", string.Join(",", list.ToArray()));
}
public bool SupportsEncoder(string decoder)
public bool SupportsEncoder(string encoder)
{
return _encoders.Contains(decoder, StringComparer.OrdinalIgnoreCase);
return _encoders.Contains(encoder, StringComparer.OrdinalIgnoreCase);
}
public bool SupportsDecoder(string decoder)

View File

@ -21,7 +21,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
protected override async Task<string> GetCommandLineArguments(EncodingJob state)
{
// Get the output codec name
var videoCodec = EncodingJobFactory.GetVideoEncoder(state, GetEncodingOptions());
var videoCodec = EncodingJobFactory.GetVideoEncoder(MediaEncoder, state, GetEncodingOptions());
var format = string.Empty;
var keyFrame = string.Empty;

View File

@ -61,14 +61,14 @@ namespace MediaBrowser.Providers.Music
{
result.Item = new MusicAlbum();
result.HasMetadata = true;
ProcessResult(result.Item, obj.album[0]);
ProcessResult(result.Item, obj.album[0], info.MetadataLanguage);
}
}
return result;
}
private void ProcessResult(MusicAlbum item, Album result)
private void ProcessResult(MusicAlbum item, Album result, string preferredLanguage)
{
if (!string.IsNullOrWhiteSpace(result.strArtist))
{
@ -91,7 +91,39 @@ namespace MediaBrowser.Providers.Music
item.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, result.strMusicBrainzArtistID);
item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, result.strMusicBrainzID);
item.Overview = (result.strDescriptionEN ?? string.Empty).StripHtml();
string overview = null;
if (string.Equals(preferredLanguage, "de", StringComparison.OrdinalIgnoreCase))
{
overview = result.strDescriptionDE;
}
else if (string.Equals(preferredLanguage, "fr", StringComparison.OrdinalIgnoreCase))
{
overview = result.strDescriptionFR;
}
else if (string.Equals(preferredLanguage, "nl", StringComparison.OrdinalIgnoreCase))
{
overview = result.strDescriptionNL;
}
else if (string.Equals(preferredLanguage, "ru", StringComparison.OrdinalIgnoreCase))
{
overview = result.strDescriptionRU;
}
else if (string.Equals(preferredLanguage, "it", StringComparison.OrdinalIgnoreCase))
{
overview = result.strDescriptionIT;
}
else if ((preferredLanguage ?? string.Empty).StartsWith("pt", StringComparison.OrdinalIgnoreCase))
{
overview = result.strDescriptionPT;
}
if (string.IsNullOrWhiteSpace(overview))
{
overview = result.strDescriptionEN;
}
item.Overview = (overview ?? string.Empty).StripHtml();
}
public string Name
@ -186,20 +218,20 @@ namespace MediaBrowser.Providers.Music
public string strAlbumThumb { get; set; }
public string strAlbumCDart { get; set; }
public string strDescriptionEN { get; set; }
public object strDescriptionDE { get; set; }
public object strDescriptionFR { get; set; }
public object strDescriptionCN { get; set; }
public object strDescriptionIT { get; set; }
public object strDescriptionJP { get; set; }
public object strDescriptionRU { get; set; }
public object strDescriptionES { get; set; }
public object strDescriptionPT { get; set; }
public object strDescriptionSE { get; set; }
public object strDescriptionNL { get; set; }
public object strDescriptionHU { get; set; }
public object strDescriptionNO { get; set; }
public object strDescriptionIL { get; set; }
public object strDescriptionPL { get; set; }
public string strDescriptionDE { get; set; }
public string strDescriptionFR { get; set; }
public string strDescriptionCN { get; set; }
public string strDescriptionIT { get; set; }
public string strDescriptionJP { get; set; }
public string strDescriptionRU { get; set; }
public string strDescriptionES { get; set; }
public string strDescriptionPT { get; set; }
public string strDescriptionSE { get; set; }
public string strDescriptionNL { get; set; }
public string strDescriptionHU { get; set; }
public string strDescriptionNO { get; set; }
public string strDescriptionIL { get; set; }
public string strDescriptionPL { get; set; }
public object intLoved { get; set; }
public object intScore { get; set; }
public string strReview { get; set; }

View File

@ -61,17 +61,16 @@ namespace MediaBrowser.Providers.Music
{
result.Item = new MusicArtist();
result.HasMetadata = true;
ProcessResult(result.Item, obj.artists[0]);
ProcessResult(result.Item, obj.artists[0], info.MetadataLanguage);
}
}
return result;
}
private void ProcessResult(MusicArtist item, Artist result)
private void ProcessResult(MusicArtist item, Artist result, string preferredLanguage)
{
item.HomePageUrl = result.strWebsite;
item.Overview = (result.strBiographyEN ?? string.Empty).StripHtml();
if (!string.IsNullOrEmpty(result.strGenre))
{
@ -80,6 +79,40 @@ namespace MediaBrowser.Providers.Music
item.SetProviderId(MetadataProviders.AudioDbArtist, result.idArtist);
item.SetProviderId(MetadataProviders.MusicBrainzArtist, result.strMusicBrainzID);
string overview = null;
if (string.Equals(preferredLanguage, "de", StringComparison.OrdinalIgnoreCase))
{
overview = result.strBiographyDE;
}
else if (string.Equals(preferredLanguage, "fr", StringComparison.OrdinalIgnoreCase))
{
overview = result.strBiographyFR;
}
else if (string.Equals(preferredLanguage, "nl", StringComparison.OrdinalIgnoreCase))
{
overview = result.strBiographyNL;
}
else if (string.Equals(preferredLanguage, "ru", StringComparison.OrdinalIgnoreCase))
{
overview = result.strBiographyRU;
}
else if (string.Equals(preferredLanguage, "it", StringComparison.OrdinalIgnoreCase))
{
overview = result.strBiographyIT;
}
else if ((preferredLanguage ?? string.Empty).StartsWith("pt", StringComparison.OrdinalIgnoreCase))
{
overview = result.strBiographyPT;
}
if (string.IsNullOrWhiteSpace(overview))
{
overview = result.strBiographyEN;
}
item.Overview = (overview ?? string.Empty).StripHtml();
}
public string Name
@ -180,18 +213,18 @@ namespace MediaBrowser.Providers.Music
public string strBiographyEN { get; set; }
public string strBiographyDE { get; set; }
public string strBiographyFR { get; set; }
public object strBiographyCN { get; set; }
public string strBiographyCN { get; set; }
public string strBiographyIT { get; set; }
public object strBiographyJP { get; set; }
public object strBiographyRU { get; set; }
public object strBiographyES { get; set; }
public object strBiographyPT { get; set; }
public object strBiographySE { get; set; }
public object strBiographyNL { get; set; }
public object strBiographyHU { get; set; }
public object strBiographyNO { get; set; }
public object strBiographyIL { get; set; }
public object strBiographyPL { get; set; }
public string strBiographyJP { get; set; }
public string strBiographyRU { get; set; }
public string strBiographyES { get; set; }
public string strBiographyPT { get; set; }
public string strBiographySE { get; set; }
public string strBiographyNL { get; set; }
public string strBiographyHU { get; set; }
public string strBiographyNO { get; set; }
public string strBiographyIL { get; set; }
public string strBiographyPL { get; set; }
public string strGender { get; set; }
public string intMembers { get; set; }
public string strCountry { get; set; }

View File

@ -923,14 +923,14 @@ namespace MediaBrowser.Server.Implementations.Library
if (type == typeof(Person))
{
var subFolderIndex = 0;
while (!char.IsLetterOrDigit(validFilename[subFolderIndex]))
foreach (char c in validFilename)
{
subFolderIndex++;
if (char.IsLetterOrDigit(c))
{
subFolderPrefix = c.ToString();
break;
}
}
subFolderPrefix = validFilename.Substring(subFolderIndex, 1);
}
var fullPath = string.IsNullOrEmpty(subFolderPrefix) ?

View File

@ -73,8 +73,8 @@
<HintPath>..\packages\SimpleInjector.3.2.0\lib\net45\SimpleInjector.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SocketHttpListener, Version=1.0.6057.1168, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SocketHttpListener.1.0.0.36\lib\net45\SocketHttpListener.dll</HintPath>
<Reference Include="SocketHttpListener, Version=1.0.6060.27027, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SocketHttpListener.1.0.0.37\lib\net45\SocketHttpListener.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />

View File

@ -9,5 +9,5 @@
<package id="morelinq" version="1.4.0" targetFramework="net45" />
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
<package id="SimpleInjector" version="3.2.0" targetFramework="net45" />
<package id="SocketHttpListener" version="1.0.0.36" targetFramework="net45" />
<package id="SocketHttpListener" version="1.0.0.37" targetFramework="net45" />
</packages>