better bitrate syncing

This commit is contained in:
Luke Pulverenti
2013-08-29 22:13:58 -04:00
parent 87c4d447f8
commit a5fa31cf94
5 changed files with 52 additions and 23 deletions

View File

@@ -93,9 +93,11 @@ namespace MediaBrowser.Api.Playback.Progressive
audioTranscodeParams.Add("-strict experimental");
}
if (request.AudioBitRate.HasValue)
var bitrate = GetAudioBitrateParam(state);
if (bitrate.HasValue)
{
audioTranscodeParams.Add("-ab " + request.AudioBitRate.Value);
audioTranscodeParams.Add("-ab " + bitrate.Value.ToString(UsCulture));
}
var channels = GetNumAudioChannelsParam(request, state.AudioStream);

View File

@@ -236,9 +236,11 @@ namespace MediaBrowser.Api.Playback.Progressive
args += " -ar " + request.AudioSampleRate.Value;
}
if (request.AudioBitRate.HasValue)
var bitrate = GetAudioBitrateParam(state);
if (bitrate.HasValue)
{
args += " -ab " + request.AudioBitRate.Value;
args += " -ab " + bitrate.Value.ToString(UsCulture);
}
var volParam = string.Empty;
@@ -283,16 +285,13 @@ namespace MediaBrowser.Api.Playback.Progressive
else if (videoCodec.Equals("mpeg4", StringComparison.OrdinalIgnoreCase))
{
args = "-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -bf 2";
}
if (state.VideoRequest.VideoBitRate.HasValue)
}
var bitrate = GetVideoBitrateParam(state);
if (bitrate.HasValue)
{
// Make sure we don't request a bitrate higher than the source
var currentBitrate = state.VideoStream == null ? state.VideoRequest.VideoBitRate.Value : state.VideoStream.BitRate ?? state.VideoRequest.VideoBitRate.Value;
var bitrate = Math.Min(currentBitrate, state.VideoRequest.VideoBitRate.Value);
args += " -b:v " + bitrate;
args += " -b:v " + bitrate.Value.ToString(UsCulture);
}
return args.Trim();