public int Mux(IMuxer muxer, IMuxerSettings settings, Action <string> logAction, Action <string> progressAction, out string outputFileName) { MkvMergeProcessRunnerService service = ServiceFactory.GetService <MkvMergeProcessRunnerService>(); outputFileName = $"{settings.VideoSourceFileName}.muxed.{settings.FileExtension}".GetNewFileName(); var parameters = service.GetAllParameters(muxer.MuxerFileName, 2); parameters .ResetParameters() .IncludeParameterWithValue("output", outputFileName) .IncludeParameterWithNoValue("options0", "no-audio") .IncludeParameterWithValue("file0", "file", settings.VideoSourceFileName) .IncludeParameterWithNoValue("options1", "no-video") .IncludeParameterWithNoValue("options1", "no-subtitles") .IncludeParameterWithNoValue("options1", "no-chapters") .IncludeParameterWithNoValue("options1", "no-attachments") .IncludeParameterWithNoValue("options1", "no-global-tags") .IncludeParameterWithValue("file1", "file", settings.AudioSourceFileName); logAction?.Invoke($"Muxing video: {settings.VideoSourceFileName} audio: {settings.AudioSourceFileName} ..."); DefaultProcessRunnerService defaultProcessRunnerService = ServiceFactory.GetService <DefaultProcessRunnerService>(); return(defaultProcessRunnerService.RunProcess(parameters, new Action <Process, string>((process, line) => progressAction?.Invoke(line)))); }
public int Encode(MediaAnalyzeInfo mediaAnalyzeInfo, string x264FileName, Action <string> logAction, Action <string> progressAction, out string outputFileName) { // Get AviSynth script AviSynthScriptService aviSynthScriptService = ServiceFactory.GetService <AviSynthScriptService>(); string avsScript = aviSynthScriptService.CreateAviSynthVideoScript(mediaAnalyzeInfo); outputFileName = $"{mediaAnalyzeInfo.Filename}.reencode.mkv".GetNewFileName(); X264ProcessRunnerService service = ServiceFactory.GetService <X264ProcessRunnerService>(); var parameters = service.GetAllParameters(x264FileName); // Pass 1 parameters .ResetParameters() .IncludeParameterWithValue("infile", avsScript) .IncludeParameterWithValue("output", outputFileName) .IncludeParameterWithValue("pass", "1") .IncludeParameterWithValue("preset", "placebo") .IncludeParameterWithValue("bitrate", Math.Ceiling(mediaAnalyzeInfo.TargetVideoBitrateInKbps).ToString("#0")) .IncludeParameterWithValue("deblock", "-1:-1") .IncludeParameterWithValue("bframes", "3") .IncludeParameterWithValue("ref", "3") .IncludeParameterWithValue("qpmin", "10") .IncludeParameterWithValue("qpmax", "51") .IncludeParameterWithValue("vbv-bufsize", "50000") .IncludeParameterWithValue("vbv-maxrate", "50000") .IncludeParameterWithValue("ratetol", "2.0") .IncludeParameterWithValue("rc-lookahead", "40") .IncludeParameterWithValue("merange", "16") .IncludeParameterWithValue("me", "umh") .IncludeParameterWithValue("subme", "6") .IncludeParameterWithValue("trellis", "1") .IncludeParameterWithNoValue("no-dct-decimate") .IncludeParameterWithValue("muxer", "mkv"); logAction?.Invoke($"Encoding {mediaAnalyzeInfo.Filename} with x264 1st pass..."); DefaultProcessRunnerService defaultProcessRunnerService = ServiceFactory.GetService <DefaultProcessRunnerService>(); defaultProcessRunnerService.RunProcess(parameters, new Action <Process, string>((process, line) => progressAction?.Invoke(line))); // Pass 2 parameters.IncludeParameterWithValue("pass", "2"); logAction?.Invoke($"Encoding {mediaAnalyzeInfo.Filename} with x264 2nd pass..."); return(defaultProcessRunnerService.RunProcess(parameters, new Action <Process, string>((process, line) => progressAction?.Invoke(line)))); }