Remove yadif, update bitrate for webm

This commit is contained in:
Luke Pulverenti 2014-01-20 10:04:50 -05:00
parent 7da8345078
commit 5917d66172
3 changed files with 28 additions and 18 deletions

View File

@ -345,7 +345,7 @@ namespace MediaBrowser.Api.Playback
var audioSampleRate = string.Empty;
var channels = GetNumAudioChannelsParam(state.Request, state.AudioStream);
// Boost volume to 200% when downsampling from 6ch to 2ch
if (channels.HasValue && channels.Value <= 2 && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5)
{
@ -375,10 +375,10 @@ namespace MediaBrowser.Api.Playback
}
}
return string.Format("-af \"{0}aresample={1}async={4}{2}{3}\"",
return string.Format("-af \"{0}aresample={1}async={4}{2}{3}\"",
adelay,
audioSampleRate,
audioSampleRate,
volParam,
pts,
state.AudioSync.ToString(UsCulture));
@ -397,7 +397,7 @@ namespace MediaBrowser.Api.Playback
var assSubtitleParam = string.Empty;
var copyTsParam = string.Empty;
var yadifParam = "yadif=0:-1:0,";
var yadifParam = state.DeInterlace ? "yadif=0:-1:0," : string.Empty;
var request = state.VideoRequest;
@ -419,7 +419,7 @@ namespace MediaBrowser.Api.Playback
var widthParam = request.Width.Value.ToString(UsCulture);
var heightParam = request.Height.Value.ToString(UsCulture);
return string.Format("{4} -vf \"{0}scale=trunc({1}/2)*2:trunc({2}/2)*2{3}\"",yadifParam, widthParam, heightParam, assSubtitleParam, copyTsParam);
return string.Format("{4} -vf \"{0}scale=trunc({1}/2)*2:trunc({2}/2)*2{3}\"", yadifParam, widthParam, heightParam, assSubtitleParam, copyTsParam);
}
var isH264Output = outputVideoCodec.Equals("libx264", StringComparison.OrdinalIgnoreCase);
@ -430,8 +430,8 @@ namespace MediaBrowser.Api.Playback
var widthParam = request.Width.Value.ToString(UsCulture);
return isH264Output ?
string.Format("{3} -vf \"{0}scale={1}:trunc(ow/a/2)*2{2}\"",yadifParam, widthParam, assSubtitleParam, copyTsParam) :
string.Format("{3} -vf \"{0}scale={1}:-1{2}\"",yadifParam, widthParam, assSubtitleParam, copyTsParam);
string.Format("{3} -vf \"{0}scale={1}:trunc(ow/a/2)*2{2}\"", yadifParam, widthParam, assSubtitleParam, copyTsParam) :
string.Format("{3} -vf \"{0}scale={1}:-1{2}\"", yadifParam, widthParam, assSubtitleParam, copyTsParam);
}
// If a fixed height was requested
@ -440,8 +440,8 @@ namespace MediaBrowser.Api.Playback
var heightParam = request.Height.Value.ToString(UsCulture);
return isH264Output ?
string.Format("{3} -vf \"{0}scale=trunc(oh*a*2)/2:{1}{2}\"",yadifParam, heightParam, assSubtitleParam, copyTsParam) :
string.Format("{3} -vf \"{0}scale=-1:{1}{2}\"",yadifParam, heightParam, assSubtitleParam, copyTsParam);
string.Format("{3} -vf \"{0}scale=trunc(oh*a*2)/2:{1}{2}\"", yadifParam, heightParam, assSubtitleParam, copyTsParam) :
string.Format("{3} -vf \"{0}scale=-1:{1}{2}\"", yadifParam, heightParam, assSubtitleParam, copyTsParam);
}
// If a max width was requested
@ -450,8 +450,8 @@ namespace MediaBrowser.Api.Playback
var maxWidthParam = request.MaxWidth.Value.ToString(UsCulture);
return isH264Output ?
string.Format("{3} -vf \"{0}scale=min(iw\\,{1}):trunc(ow/a/2)*2{2}\"",yadifParam, maxWidthParam, assSubtitleParam, copyTsParam) :
string.Format("{3} -vf \"{0}scale=min(iw\\,{1}):-1{2}\"",yadifParam, maxWidthParam, assSubtitleParam, copyTsParam);
string.Format("{3} -vf \"{0}scale=min(iw\\,{1}):trunc(ow/a/2)*2{2}\"", yadifParam, maxWidthParam, assSubtitleParam, copyTsParam) :
string.Format("{3} -vf \"{0}scale=min(iw\\,{1}):-1{2}\"", yadifParam, maxWidthParam, assSubtitleParam, copyTsParam);
}
// If a max height was requested
@ -460,8 +460,8 @@ namespace MediaBrowser.Api.Playback
var maxHeightParam = request.MaxHeight.Value.ToString(UsCulture);
return isH264Output ?
string.Format("{3} -vf \"{0}scale=trunc(oh*a*2)/2:min(ih\\,{1}){2}\"",yadifParam, maxHeightParam, assSubtitleParam, copyTsParam) :
string.Format("{3} -vf \"{0}scale=-1:min(ih\\,{1}){2}\"",yadifParam, maxHeightParam, assSubtitleParam, copyTsParam);
string.Format("{3} -vf \"{0}scale=trunc(oh*a*2)/2:min(ih\\,{1}){2}\"", yadifParam, maxHeightParam, assSubtitleParam, copyTsParam) :
string.Format("{3} -vf \"{0}scale=-1:min(ih\\,{1}){2}\"", yadifParam, maxHeightParam, assSubtitleParam, copyTsParam);
}
if (state.VideoStream == null)
@ -484,11 +484,11 @@ namespace MediaBrowser.Api.Playback
var widthParam = outputSize.Width.ToString(UsCulture);
var heightParam = outputSize.Height.ToString(UsCulture);
return string.Format("{4} -vf \"{0}scale=trunc({1}/2)*2:trunc({2}/2)*2{3}\"",yadifParam, widthParam, heightParam, assSubtitleParam, copyTsParam);
return string.Format("{4} -vf \"{0}scale=trunc({1}/2)*2:trunc({2}/2)*2{3}\"", yadifParam, widthParam, heightParam, assSubtitleParam, copyTsParam);
}
// Otherwise use -vf scale since ffmpeg will ensure internally that the aspect ratio is preserved
return string.Format("{3} -vf \"{0}scale={1}:-1{2}\"",yadifParam, Convert.ToInt32(outputSize.Width), assSubtitleParam, copyTsParam);
return string.Format("{3} -vf \"{0}scale={1}:-1{2}\"", yadifParam, Convert.ToInt32(outputSize.Width), assSubtitleParam, copyTsParam);
}
/// <summary>
@ -509,7 +509,7 @@ namespace MediaBrowser.Api.Playback
var seconds = TimeSpan.FromTicks(state.Request.StartTimeTicks ?? 0).TotalSeconds;
return string.Format(",ass='{0}',setpts=PTS -{1}/TB",
return string.Format(",ass='{0}',setpts=PTS -{1}/TB",
path.Replace('\\', '/').Replace(":/", "\\:/"),
Math.Round(seconds).ToString(UsCulture));
}
@ -1061,6 +1061,7 @@ namespace MediaBrowser.Api.Playback
//state.RunTimeTicks = recording.RunTimeTicks;
state.SendInputOverStandardInput = recording.RecordingInfo.Status == RecordingStatus.InProgress;
state.AudioSync = 1000;
state.DeInterlace = true;
}
else if (item is LiveTvChannel)
{
@ -1087,6 +1088,7 @@ namespace MediaBrowser.Api.Playback
state.SendInputOverStandardInput = true;
state.AudioSync = 1000;
state.DeInterlace = true;
}
else
{

View File

@ -169,8 +169,14 @@ namespace MediaBrowser.Api.Playback.Progressive
if (bitrate.HasValue)
{
qualityParam += string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture));
//qualityParam += string.Format(" -maxrate {0} -bufsize {1}", bitrate.Value.ToString(UsCulture), (bitrate.Value * 2).ToString(UsCulture));
if (string.Equals(codec, "libvpx", StringComparison.OrdinalIgnoreCase))
{
qualityParam += string.Format(" -minrate:v ({0}*.90) -maxrate:v ({0}*1.10) -bufsize:v {0} -b:v {0}", bitrate.Value.ToString(UsCulture));
}
else
{
qualityParam += string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture));
}
}
if (!string.IsNullOrEmpty(qualityParam))

View File

@ -60,5 +60,7 @@ namespace MediaBrowser.Api.Playback
public long? RunTimeTicks;
public int AudioSync = 1;
public bool DeInterlace { get; set; }
}
}