@@ -104,19 +104,33 @@ public EACDemuxer(string eacPath, string fileName, TaskProfile jobProfile)
104104 Logger . Debug ( $ "SkipAllAudioTracks: { jobProfile . SkipAllAudioTracks } , SkipAllSubtitleTracks: { jobProfile . SkipAllSubtitleTracks } ") ;
105105 }
106106
107- private void StartEac ( string arguments , bool asyncRead )
107+ private void StartEac ( string arguments , string logPath , bool asyncRead )
108108 {
109+ // Since eac3to does not support log paths containing spaces, we first calculate a short hash
110+ // from the intended log path to serve as the log filename. We then launch eac3to in the
111+ // working directory to generate the log, and finally rename the log file back to its full name.
112+ var workingPathDir = Path . GetDirectoryName ( WorkingPathPrefix ) ;
113+ var logPathFull = Path . Combine ( workingPathDir , logPath ) ;
114+ byte [ ] buffer = Encoding . UTF8 . GetBytes ( logPathFull ) ;
115+ var crc = CRC32 . Compute ( buffer ) ;
116+ var logHashPath = crc . ToString ( "X8" ) + ".eac3to.log" ;
117+
118+ Logger . Trace ( $ "workingPathDir: { workingPathDir } ") ;
119+ Logger . Trace ( $ "eac3to logPathFull: { logPathFull } ") ;
120+ Logger . Trace ( $ "eac3to logHashPath: { logHashPath } ") ;
121+
109122 var startInfo = new ProcessStartInfo
110123 {
111124 FileName = _eacPath ,
112- Arguments = arguments + " -progressnumbers" ,
125+ Arguments = arguments + $ " -log= \" { logHashPath } \" " + " -progressnumbers" ,
113126 RedirectStandardOutput = true ,
114127 RedirectStandardError = true ,
115128 StandardOutputEncoding = Encoding . UTF8 ,
116129 StandardErrorEncoding = Encoding . UTF8 ,
117130 UseShellExecute = false ,
118131 WindowStyle = ProcessWindowStyle . Hidden ,
119132 CreateNoWindow = true ,
133+ WorkingDirectory = workingPathDir ,
120134 } ;
121135 Logger . Info ( startInfo . FileName + " " + startInfo . Arguments ) ;
122136
@@ -135,6 +149,24 @@ private void StartEac(string arguments, bool asyncRead)
135149 readStream ( proc . StandardOutput ) ;
136150 proc . WaitForExit ( ) ;
137151 }
152+
153+ FileInfo logFile = new FileInfo ( Path . Combine ( workingPathDir , logHashPath ) ) ;
154+ if ( logFile . Exists )
155+ {
156+ FileInfo logFileFinal = new FileInfo ( logPathFull ) ;
157+ if ( logFileFinal . Exists )
158+ {
159+ logFileFinal . Delete ( ) ;
160+ }
161+ logFile . MoveTo ( logPathFull ) ;
162+ }
163+
164+ if ( proc . ExitCode != 0 )
165+ {
166+ OKETaskException ex = new OKETaskException ( Constants . eac3toErrorSmr ) ;
167+ ex . Data [ "EXIT_CODE" ] = proc . ExitCode ;
168+ throw ex ;
169+ }
138170 }
139171 catch ( Exception e ) { throw e ; }
140172 }
@@ -295,10 +327,14 @@ public MediaFile Extract(Action<double, EACProgressType> progressCallback)
295327 {
296328 return null ;
297329 }
330+
331+ var baseName = Path . GetFileNameWithoutExtension ( sourceFile ) ;
332+ string logPath = $ "{ baseName } .eac3to.log";
333+
298334 _progressCallback = progressCallback ;
299335
300336 state = ProcessState . FetchStream ;
301- StartEac ( $ "\" { sourceFile } \" ", false ) ;
337+ StartEac ( $ "\" { sourceFile } \" ", logPath , false ) ;
302338
303339 if ( SkipAllAudioTracks )
304340 {
@@ -390,7 +426,7 @@ public MediaFile Extract(Action<double, EACProgressType> progressCallback)
390426 JobSub . RemoveAll ( info => info . MuxOption == MuxOption . Skip ) ;
391427
392428 state = ProcessState . ExtractStream ;
393- StartEac ( $ "\" { sourceFile } \" { string . Join ( " " , args ) } ", true ) ;
429+ StartEac ( $ "\" { sourceFile } \" { string . Join ( " " , args ) } ", logPath , true ) ;
394430
395431 foreach ( TrackInfo track in extractResult )
396432 {
0 commit comments