fix mp4 sync encoding

This commit is contained in:
Luke Pulverenti 2015-03-27 16:55:31 -04:00
parent d7a979979b
commit d8cbd64917
13 changed files with 82 additions and 41 deletions

View File

@ -38,6 +38,7 @@ namespace MediaBrowser.Controller.Channels
public string Id { get; set; }
public bool ReadAtNativeFramerate { get; set; }
public bool SupportsDirectPlay { get; set; }
public ChannelMediaInfo()
{
@ -45,6 +46,7 @@ namespace MediaBrowser.Controller.Channels
// This is most common
Protocol = MediaProtocol.Http;
SupportsDirectPlay = true;
}
public MediaSourceInfo ToMediaSource()
@ -63,7 +65,8 @@ namespace MediaBrowser.Controller.Channels
Name = id,
Id = id,
ReadAtNativeFramerate = ReadAtNativeFramerate,
SupportsDirectStream = Protocol == MediaProtocol.File || Protocol == MediaProtocol.Http
SupportsDirectStream = Protocol == MediaProtocol.File || Protocol == MediaProtocol.Http,
SupportsDirectPlay = SupportsDirectPlay
};
var bitrate = (AudioBitrate ?? 0) + (VideoBitrate ?? 0);

View File

@ -73,10 +73,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
args;
}
if (state.Options.Context == EncodingContext.Streaming)
{
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
5.ToString(UsCulture));
args += keyFrameArg;
}
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;

View File

@ -1,7 +1,6 @@
using MediaBrowser.Model.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Model.ApiClient
{
@ -24,7 +23,12 @@ namespace MediaBrowser.Model.ApiClient
throw new ArgumentNullException("server");
}
var list = Servers.ToList();
// Clone the existing list of servers
var list = new List<ServerInfo>();
foreach (ServerInfo serverInfo in Servers)
{
list.Add(serverInfo);
}
var index = FindIndex(list, server.Id);
@ -32,8 +36,11 @@ namespace MediaBrowser.Model.ApiClient
{
var existing = list[index];
// Merge the data
existing.DateLastAccessed = new[] { existing.DateLastAccessed, server.DateLastAccessed }.Max();
// Take the most recent DateLastAccessed
if (server.DateLastAccessed > existing.DateLastAccessed)
{
existing.DateLastAccessed = server.DateLastAccessed;
}
existing.UserLinkType = server.UserLinkType;
@ -64,7 +71,11 @@ namespace MediaBrowser.Model.ApiClient
}
if (server.WakeOnLanInfos != null && server.WakeOnLanInfos.Count > 0)
{
existing.WakeOnLanInfos = server.WakeOnLanInfos.ToList();
existing.WakeOnLanInfos = new List<WakeOnLanInfo>();
foreach (WakeOnLanInfo info in server.WakeOnLanInfos)
{
existing.WakeOnLanInfos.Add(info);
}
}
if (server.LastConnectionMode.HasValue)
{

View File

@ -3,7 +3,6 @@ using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.System;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Model.ApiClient
{
@ -83,7 +82,12 @@ namespace MediaBrowser.Model.ApiClient
throw new ArgumentNullException("user");
}
var list = Users.ToList();
// Clone the existing list of users
var list = new List<ServerUserInfo>();
foreach (ServerUserInfo serverUserInfo in Users)
{
list.Add(serverUserInfo);
}
var index = FindIndex(list, user.Id);

View File

@ -28,7 +28,7 @@ namespace MediaBrowser.Model.Dlna
case PlayMethod.DirectPlay:
return 0;
default:
return 2;
return 1;
}
}).ThenBy(i =>

View File

@ -333,10 +333,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
try
{
MediaSourceInfo info;
var isVideo = true;
if (isChannel)
{
var channel = GetInternalChannel(id);
isVideo = channel.ChannelType == ChannelType.TV;
var service = GetService(channel);
_logger.Info("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId);
info = await service.GetChannelStream(channel.ExternalId, null, cancellationToken).ConfigureAwait(false);
@ -344,6 +346,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
else
{
var recording = await GetInternalRecording(id, cancellationToken).ConfigureAwait(false);
isVideo = !string.Equals(recording.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase);
var service = GetService(recording);
_logger.Info("Opening recording stream from {0}, external recording Id: {1}", service.Name, recording.RecordingInfo.Id);
@ -351,7 +354,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}
_logger.Info("Live stream info: {0}", _jsonSerializer.SerializeToString(info));
Sanitize(info);
Normalize(info, isVideo);
var data = new LiveStreamData
{
@ -377,9 +380,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}
}
private void Sanitize(MediaSourceInfo mediaSource)
private void Normalize(MediaSourceInfo mediaSource, bool isVideo)
{
if (mediaSource.MediaStreams.Count == 0)
{
if (isVideo)
{
mediaSource.MediaStreams.AddRange(new List<MediaStream>
{
@ -397,6 +402,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}
});
}
else
{
mediaSource.MediaStreams.AddRange(new List<MediaStream>
{
new MediaStream
{
Type = MediaStreamType.Audio,
// Set the index to -1 because we don't know the exact index of the audio stream within the container
Index = -1
}
});
}
}
// Clean some bad data coming from providers
foreach (var stream in mediaSource.MediaStreams)

View File

@ -1,5 +1,4 @@
using System.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Sync;
@ -10,6 +9,7 @@ using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Sync;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
@ -140,9 +140,6 @@ namespace MediaBrowser.Server.Implementations.Sync
var libraryItem = jobItem.Item;
var internalSyncJobItem = _syncManager.GetJobItem(jobItem.SyncJobItemId);
var fileTransferProgress = new ActionableProgress<double>();
fileTransferProgress.RegisterAction(pct => progress.Report(pct * .92));
var localItem = CreateLocalItem(provider, jobItem, target, libraryItem, serverId, jobItem.OriginalFileName);
await _syncManager.ReportSyncJobItemTransferBeginning(internalSyncJobItem.Id);
@ -152,6 +149,9 @@ namespace MediaBrowser.Server.Implementations.Sync
try
{
var fileTransferProgress = new ActionableProgress<double>();
fileTransferProgress.RegisterAction(pct => progress.Report(pct * .92));
var sendFileResult = await SendFile(provider, internalSyncJobItem.OutputPath, localItem.LocalPath, target, fileTransferProgress, cancellationToken).ConfigureAwait(false);
if (localItem.Item.MediaSources != null)
@ -342,7 +342,10 @@ namespace MediaBrowser.Server.Implementations.Sync
private string GetSyncJobFolderName(SyncedItem syncedItem, IServerSyncProvider provider)
{
var name = syncedItem.SyncJobName + syncedItem.SyncJobDateCreated.ToLocalTime().ToString("g");
var name = syncedItem.SyncJobName + "-" + syncedItem.SyncJobDateCreated
.ToLocalTime()
.ToString("g")
.Replace(" ", "-");
name = GetValidFilename(provider, name);

View File

@ -139,7 +139,6 @@ namespace MediaBrowser.Server.Mono.Native
}
else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
{
// TODO: How to detect BSD?
info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
}

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.599</version>
<version>3.0.600</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.599" />
<dependency id="MediaBrowser.Common" version="3.0.600" />
<dependency id="NLog" version="3.2.0.0" />
<dependency id="SimpleInjector" version="2.7.0" />
</dependencies>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.599</version>
<version>3.0.600</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Model.Signed</id>
<version>3.0.599</version>
<version>3.0.600</version>
<title>MediaBrowser.Model - Signed Edition</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.599</version>
<version>3.0.600</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.599" />
<dependency id="MediaBrowser.Common" version="3.0.600" />
</dependencies>
</metadata>
<files>

View File

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("3.0.*")]
//[assembly: AssemblyVersion("3.0.5557.20000")]
//[assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyVersion("3.0.5557.30000")]