From ebd9ab3ccc2a152b2f950d8948f018fadf5e8916 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Wed, 9 Dec 2020 14:39:11 +0800 Subject: [PATCH 1/2] use larger batch size on mpegts to avoid corrupted thumbnails --- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index b1da9c712d..4c804371ed 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -603,16 +603,19 @@ namespace MediaBrowser.MediaEncoding.Encoder } // Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case. + // mpegts need larger batch size otherwise the corrupted thumbnail will be created. Larger batch size will lower the processing speed. var enableThumbnail = useIFrame && !string.Equals("wtv", container, StringComparison.OrdinalIgnoreCase); + var useLargerBatchSize = string.Equals("mpegts", container, StringComparison.OrdinalIgnoreCase); if (enableThumbnail) { + var batchSize = useLargerBatchSize ? "50" : "24"; if (string.IsNullOrEmpty(vf)) { - vf = "-vf thumbnail=24"; + vf = "-vf thumbnail=" + batchSize; } else { - vf += ",thumbnail=24"; + vf += ",thumbnail=" + batchSize; } } From 060f6c194f186eccd4eede7426a65e3496fdcf45 Mon Sep 17 00:00:00 2001 From: Nyanmisaka Date: Wed, 9 Dec 2020 16:37:15 +0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Claus Vium --- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 4c804371ed..fbd08a97c7 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -605,9 +605,9 @@ namespace MediaBrowser.MediaEncoding.Encoder // Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case. // mpegts need larger batch size otherwise the corrupted thumbnail will be created. Larger batch size will lower the processing speed. var enableThumbnail = useIFrame && !string.Equals("wtv", container, StringComparison.OrdinalIgnoreCase); - var useLargerBatchSize = string.Equals("mpegts", container, StringComparison.OrdinalIgnoreCase); if (enableThumbnail) { + var useLargerBatchSize = string.Equals("mpegts", container, StringComparison.OrdinalIgnoreCase); var batchSize = useLargerBatchSize ? "50" : "24"; if (string.IsNullOrEmpty(vf)) {