@@ -82,6 +82,7 @@ public class MainViewModel : ViewModelBase
8282 private bool encoding ;
8383 private bool paused ;
8484 private bool encodeStopped ;
85+ private bool errorLoggedDuringJob ; // True if an error was logged during an encode (and no scan was going on at the time)
8586 private int totalTasks ;
8687 private int taskNumber ;
8788 private bool encodeSpeedDetailsAvailable ;
@@ -93,6 +94,7 @@ public class MainViewModel : ViewModelBase
9394 private double completedQueueWork ;
9495 private double totalQueueCost ;
9596 private double overallEncodeProgressFraction ;
97+ private TimeSpan currentJobEta ; // Kept around to check if the job finished early
9698 private TaskbarItemProgressState encodeProgressState ;
9799 private ObservableCollection < EncodeResultViewModel > completedJobs ;
98100
@@ -203,8 +205,8 @@ public MainViewModel()
203205 this . encodeQueue . Add ( new EncodeJobViewModel ( job ) ) ;
204206 }
205207
206- this . autoPause . PauseEncoding += new EventHandler ( this . AutoPauseEncoding ) ;
207- this . autoPause . ResumeEncoding += new EventHandler ( this . AutoResumeEncoding ) ;
208+ this . autoPause . PauseEncoding += this . AutoPauseEncoding ;
209+ this . autoPause . ResumeEncoding += this . AutoResumeEncoding ;
208210
209211 // Always select the modified preset if it exists.
210212 // Otherwise, choose the last selected preset.
@@ -223,6 +225,15 @@ public MainViewModel()
223225 presetIndex = 0 ;
224226 }
225227
228+ // Keep track of errors logged. HandBrake doesn't reliably report errors on job completion.
229+ this . logger . EntryLogged += ( sender , e ) =>
230+ {
231+ if ( e . Value . LogType == LogType . Error && this . Encoding && ! this . ScanningSource )
232+ {
233+ this . errorLoggedDuringJob = true ;
234+ }
235+ } ;
236+
226237 this . SelectedPreset = this . allPresets [ presetIndex ] ;
227238
228239 this . completedJobs = new ObservableCollection < EncodeResultViewModel > ( ) ;
@@ -2566,6 +2577,8 @@ private void StartEncode()
25662577 }
25672578 }
25682579
2580+ this . currentJobEta = TimeSpan . Zero ;
2581+ this . errorLoggedDuringJob = false ;
25692582 this . EncodeQueue [ 0 ] . ReportEncodeStart ( this . totalTasks == 1 ) ;
25702583 this . CurrentJob . HandBrakeInstance . StartEncode ( this . CurrentJob . Job ) ;
25712584 }
@@ -2641,9 +2654,9 @@ private void OnEncodeProgress(object sender, EncodeProgressEventArgs e)
26412654
26422655 double currentJobRemainingWork = this . EncodeQueue [ 0 ] . Cost - currentJobCompletedWork ;
26432656
2644- TimeSpan currentJobEta =
2657+ this . currentJobEta =
26452658 TimeSpan . FromSeconds ( currentJobRemainingWork / overallWorkCompletionRate ) ;
2646- this . EncodeQueue [ 0 ] . Eta = currentJobEta ;
2659+ this . EncodeQueue [ 0 ] . Eta = this . currentJobEta ;
26472660 }
26482661 }
26492662
@@ -2688,17 +2701,27 @@ private void OnEncodeCompleted(object sender, EncodeCompletedEventArgs e)
26882701 if ( e . Error )
26892702 {
26902703 succeeded = false ;
2691- this . logger . Log ( "Encode failed. HandBrake reported an error." ) ;
2704+ this . logger . LogError ( "Encode failed. HandBrake reported an error." ) ;
2705+ }
2706+ else if ( this . errorLoggedDuringJob )
2707+ {
2708+ succeeded = false ;
2709+ this . logger . LogError ( "Encode failed. Error(s) were reported during the encode." ) ;
26922710 }
26932711 else if ( ! outputFileInfo . Exists )
26942712 {
26952713 succeeded = false ;
2696- this . logger . Log ( "Encode failed. HandBrake reported no error but the expected output file was not found." ) ;
2714+ this . logger . LogError ( "Encode failed. HandBrake reported no error but the expected output file was not found." ) ;
26972715 }
26982716 else if ( outputFileInfo . Length == 0 )
26992717 {
27002718 succeeded = false ;
2701- this . logger . Log ( "Encode failed. HandBrake reported no error but the output file was empty." ) ;
2719+ this . logger . LogError ( "Encode failed. HandBrake reported no error but the output file was empty." ) ;
2720+ }
2721+ else if ( this . currentJobEta > TimeSpan . FromMinutes ( 1 ) )
2722+ {
2723+ succeeded = false ;
2724+ this . logger . LogError ( "Encode failed. HandBrake reported no error but the encode finished prematurely." ) ;
27022725 }
27032726
27042727 this . CompletedJobs . Add ( new EncodeResultViewModel (
0 commit comments