using System; using System.Diagnostics; using System.IO; namespace youtube_downloader.Server.Functions { internal class ffmpeg { internal static string FFMPEG = ffmpeg.get_ffmpeg(); private static string get_ffmpeg() { if (File.Exists("ffmpeg.txt")) { return File.ReadAllText("ffmpeg.txt"); } return "ffmpeg"; } internal static void mux(string mypath, string mypathCompleteAudio, string mypathIncompleteConverting) { using (var p = new Process()) { p.StartInfo.FileName = FFMPEG; p.StartInfo.Arguments = $"-i \"{mypath}\' -i \"{mypathCompleteAudio}\" -c copy -map 0:v -map 1:a \"{mypathIncompleteConverting}\'"; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; if (p.Start()) { p.WaitForExit(); } } } internal static void download_thumbnail(string tnail, string p2) { using (var p = new Process()) { p.StartInfo.FileName = FFMPEG; p.StartInfo.Arguments = $"-i \"{tnail}\' \"{p2}\'"; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; if (p.Start()) { p.WaitForExit(); } } } } public class ProgressTwo { double vanda; double v; double a; double vval=0; double aval=0; IProgress report; public ProgressTwo(double vsize,double asize,IProgress p) { vanda = vsize + asize; v = vsize / vanda; //v = 0.1 if vsize == 20 and vanda=200 a = asize / vanda; Video = new Progress(ProgressVideo); Audio = new Progress(ProgressAudio); report = p; } private void ProgressAudio(double d) { aval = d * a; Process(); } private void ProgressVideo(double d) { vval = d * v; Process(); } private void Process() { report.Report(aval + vval); } public Progress Video { get; set; } public Progress Audio { get; set; } } }