Guest User

Untitled

a guest
Jul 10th, 2025
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let output = Flow.TempPath + '/' + Flow.NewGuid() + '.mkv';
  2. let handbrake = Flow.GetToolPath('handbrakecli');
  3. let presetFilePath = Variables.presetFilePath;
  4. let presetName = Variables.presetName;
  5.  
  6. let executeArgs = new ExecuteArgs();
  7.  
  8. executeArgs.command = handbrake;
  9. executeArgs.argumentList = [
  10.         '--preset-import-file', presetFilePath,
  11.         '-Z', presetName,
  12.         '-i', Variables.file.FullName,
  13.         '-o', output
  14.     ];
  15. executeArgs.workingDirectory = Flow.TempPath + '/';
  16.  
  17. executeArgs.add_Output((line) => {
  18.     let matches = line.match(/^Encoding: task (?<task>\d) of (?<totalTasks>\d), (?<percentage>\d+\.\d+) % \((?<fps>\d+\.\d+ fps), avg (?<avgfps>\d+\.\d+ fps), ETA (?<eta>\d+h\d+s)\)$/);
  19.     if (matches) {
  20.         Flow.PartPercentageUpdate(matches.groups.percentage);
  21.         Flow.AdditionalInfoRecorder('stage',matches.groups.task + ' of ' +  matches.groups.totalTasks);
  22.         Flow.AdditionalInfoRecorder('fps',matches.groups.fps);
  23.         Flow.AdditionalInfoRecorder('avgfps',matches.groups.avgfps);
  24.         Flow.AdditionalInfoRecorder('eta',matches.groups.eta);
  25.     }
  26. });
  27.  
  28. let process = Flow.Execute(executeArgs);
  29.  
  30. if(process.exitCode !== 0){
  31.     Logger.ELog('Failed processing ffmpeg: ' + process.exitCode);
  32.     return -1;
  33. }
  34.  
  35. if(Flow.FileExists(output) !== true)
  36. {
  37.     Logger.ELog('Output file does not exist from HandBrakeCLI: ' + output);
  38.     return -1;
  39. }
  40.  
  41. Flow.SetWorkingFile(output);
  42. return 1;
Advertisement
Add Comment
Please, Sign In to add comment