mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
Merge pull request #3877 from orryverducci/deinterlace-improvements
Deinterlacing improvements
This commit is contained in:
commit
9cbc016b0a
3 changed files with 35 additions and 20 deletions
|
@ -78,6 +78,7 @@
|
|||
- [nvllsvm](https://github.com/nvllsvm)
|
||||
- [nyanmisaka](https://github.com/nyanmisaka)
|
||||
- [oddstr13](https://github.com/oddstr13)
|
||||
- [orryverducci](https://github.com/orryverducci)
|
||||
- [petermcneil](https://github.com/petermcneil)
|
||||
- [Phlogi](https://github.com/Phlogi)
|
||||
- [pjeanjean](https://github.com/pjeanjean)
|
||||
|
|
|
@ -2090,6 +2090,9 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
var hasTextSubs = state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
||||
// If double rate deinterlacing is enabled and the input framerate is 30fps or below, otherwise the output framerate will be too high for many devices
|
||||
var doubleRateDeinterlace = options.DeinterlaceDoubleRate && (videoStream?.RealFrameRate ?? 60) <= 30;
|
||||
|
||||
// When the input may or may not be hardware VAAPI decodable
|
||||
if (isVaapiH264Encoder)
|
||||
{
|
||||
|
@ -2136,35 +2139,38 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
{
|
||||
if (isVaapiH264Encoder)
|
||||
{
|
||||
filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_vaapi"));
|
||||
filters.Add(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"deinterlace_vaapi=rate={0}",
|
||||
doubleRateDeinterlace ? "field" : "frame"));
|
||||
}
|
||||
}
|
||||
|
||||
// Add software deinterlace filter before scaling filter
|
||||
if (state.DeInterlace("h264", true)
|
||||
|| state.DeInterlace("avc", true)
|
||||
|| state.DeInterlace("h265", true)
|
||||
|| state.DeInterlace("hevc", true))
|
||||
if ((state.DeInterlace("h264", true)
|
||||
|| state.DeInterlace("avc", true)
|
||||
|| state.DeInterlace("h265", true)
|
||||
|| state.DeInterlace("hevc", true))
|
||||
&& !isVaapiH264Encoder
|
||||
&& !isQsvH264Encoder
|
||||
&& !isNvdecH264Decoder)
|
||||
{
|
||||
string deintParam;
|
||||
var inputFramerate = videoStream?.RealFrameRate;
|
||||
|
||||
// If it is already 60fps then it will create an output framerate that is much too high for roku and others to handle
|
||||
if (string.Equals(options.DeinterlaceMethod, "yadif_bob", StringComparison.OrdinalIgnoreCase) && (inputFramerate ?? 60) <= 30)
|
||||
if (string.Equals(options.DeinterlaceMethod, "bwdif", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
deintParam = "yadif=1:-1:0";
|
||||
filters.Add(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"bwdif={0}:-1:0",
|
||||
doubleRateDeinterlace ? "1" : "0"));
|
||||
}
|
||||
else
|
||||
{
|
||||
deintParam = "yadif=0:-1:0";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(deintParam))
|
||||
{
|
||||
if (!isVaapiH264Encoder && !isQsvH264Encoder && !isNvdecH264Decoder)
|
||||
{
|
||||
filters.Add(deintParam);
|
||||
}
|
||||
filters.Add(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"yadif={0}:-1:0",
|
||||
doubleRateDeinterlace ? "1" : "0"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2397,6 +2403,11 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
if (state.DeInterlace("h264", true))
|
||||
{
|
||||
inputModifier += " -deint 1";
|
||||
|
||||
if (!encodingOptions.DeinterlaceDoubleRate || (videoStream?.RealFrameRate ?? 60) > 30)
|
||||
{
|
||||
inputModifier += " -drop_second_field 1";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ namespace MediaBrowser.Model.Configuration
|
|||
|
||||
public string EncoderPreset { get; set; }
|
||||
|
||||
public bool DeinterlaceDoubleRate { get; set; }
|
||||
|
||||
public string DeinterlaceMethod { get; set; }
|
||||
|
||||
public bool EnableDecodingColorDepth10Hevc { get; set; }
|
||||
|
@ -60,6 +62,7 @@ namespace MediaBrowser.Model.Configuration
|
|||
VaapiDevice = "/dev/dri/renderD128";
|
||||
H264Crf = 23;
|
||||
H265Crf = 28;
|
||||
DeinterlaceDoubleRate = false;
|
||||
DeinterlaceMethod = "yadif";
|
||||
EnableDecodingColorDepth10Hevc = true;
|
||||
EnableDecodingColorDepth10Vp9 = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue