Browse Source

Update MediaEncoder.cs

Currently, the extraction routine is giving ffmpeg 2 minutes to get all the thumbnails from a video.  For most videos, this is not enough time.  Updating the routine here to poll thumbnail output every 2 minutes, and assume that ffmpeg is still doing well if new jpegs are being created.
Bluebull32 10 years ago
parent
commit
9b41a0001c
1 changed files with 15 additions and 1 deletions
  1. 15 1
      MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

+ 15 - 1
MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

@@ -501,7 +501,21 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
 
             process.Start();
             process.Start();
 
 
-            var ranToCompletion = process.WaitForExit(120000);
+            // Need to give ffmpeg enough time to make all the thumbnails, which could be a while,
+            // but we still need to detect if the process hangs.
+            // Making the assumption that as long as new jpegs are showing up, everything is good.
+
+            bool isResponsive = true;
+            int lastCount = 0;
+
+            while (isResponsive && !process.WaitForExit(120000))
+            {
+                int jpegCount = Directory.GetFiles(targetDirectory, "*.jpg").Count();
+                isResponsive = (jpegCount > lastCount);
+                lastCount = jpegCount;
+            }
+
+            bool ranToCompletion = process.HasExited;
 
 
             if (!ranToCompletion)
             if (!ranToCompletion)
             {
             {