public EncodedVideo EncodeVideo(VideoFile input, string encodingCommand, string outputFile, bool getVideoThumbnail) { EncodedVideo encoded = new EncodedVideo(); Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); string output = RunProcess(Params); encoded.EncodingLog = output; encoded.EncodedVideoPath = outputFile; if (File.Exists(outputFile)) { encoded.Success = true; //get thumbnail? if (getVideoThumbnail) { string saveThumbnailTo = outputFile + "_thumb.jpg"; if (GetVideoThumbnail(input, saveThumbnailTo)) { encoded.ThumbnailPath = saveThumbnailTo; } } } else { encoded.Success = false; } return encoded; }
public EncodedVideo EncodeVideo(VideoFile input, string encodingCommand, string outputFile, bool getVideoThumbnail) { EncodedVideo encoded = new EncodedVideo(); Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); string output = RunProcess(Params); encoded.EncodingLog = output; encoded.EncodedVideoPath = outputFile; if (File.Exists(outputFile)) { encoded.Success = true; if (getVideoThumbnail) { string saveThumbnailTo = outputFile + "_thumb.jpg"; if (GetVideoThumbnail(input, saveThumbnailTo)) { encoded.ThumbnailPath = saveThumbnailTo; } } } else { encoded.Success = false; } return(encoded); }
public void EncodeVideoAsync(VideoFile input, string encodingCommand, string outputFile, System.Windows.Forms.Control caller, int threadCount) { //Gather info if (!input.infoGathered) { GetVideoInfo(input); } //encoded video oluşturuyorum tempEncodedVideo = new EncodedVideo(); tempEncodedVideo.EncodedVideoPath = outputFile; tempCaller = caller; tempVideoFile = input; //Create parameters if (threadCount.Equals(1)) { Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); } else { Params = string.Format("-i \"{0}\" -threads {1} {2} \"{3}\"", input.Path, threadCount.ToString(), encodingCommand, outputFile); } //Execute ffmpeg async RunProcessAsync(Params); }
public EncodedVideo EncodeVideo(VideoFile input, string encodingCommand, string outputFile, bool getVideoThumbnail) { EncodedVideo encodedVideo = new EncodedVideo(); Params = $"-i {input.File} {encodingCommand} {outputFile}"; string text2 = encodedVideo.EncodingLog = RunProcess(Params); encodedVideo.EncodedVideoPath = outputFile; if (File.Exists(outputFile)) { encodedVideo.Success = true; if (getVideoThumbnail) { string text3 = outputFile + "_thumb.jpg"; if (GetVideoThumbnail(input, text3)) { encodedVideo.ThumbnailPath = text3; } } } else { encodedVideo.Success = false; } return(encodedVideo); }
public void EncodeVideoAsyncAutoCommand(VideoFile input, string outputFile, System.Windows.Forms.Control caller, int treadCount) { if (!input.infoGathered) { GetVideoInfo(input); } if (input.VideoBitRate == 0) { int h = input.Height; if (h < 180) { input.VideoBitRate = 400; } else if (h < 260) { input.VideoBitRate = 1000; } else if (h < 400) { input.VideoBitRate = 2000; } else if (h < 800) { input.VideoBitRate = 5000; } else { input.VideoBitRate = 8000; } } if (input.AudioBitRate == 0) { input.AudioBitRate = 128; } string encodingCommand = String.Format("-threads {0} -y -b {1} -ab {2}", treadCount.ToString(), input.VideoBitRate.ToString() + "k", input.AudioBitRate.ToString() + "k"); tempEncodedVideo = new EncodedVideo(); tempEncodedVideo.EncodedVideoPath = outputFile; tempCaller = caller; tempVideoFile = input; Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); RunProcessAsync(Params); }
public EncodedVideo EncodeVideo(VideoFile input, string encodingCommand, string outputFile, bool getVideoThumbnail) { EncodedVideo video = new EncodedVideo(); this.Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); string str = this.RunProcess(this.Params); video.EncodingLog = str; video.EncodedVideoPath = outputFile; if (File.Exists(outputFile)) { video.Success = true; if (getVideoThumbnail) { string saveThumbnailTo = outputFile + "_thumb.jpg"; if (this.GetVideoThumbnail(input, saveThumbnailTo)) { video.ThumbnailPath = saveThumbnailTo; } } return video; } video.Success = false; return video; }
public void EncodeVideoAsyncAutoCommand(VideoFile input, string outputFile, Control caller, int treadCount) { if (!input.infoGathered) { this.GetVideoInfo(input); } if (input.VideoBitRate == 0.0) { int height = input.Height; if (height < 180) { input.VideoBitRate = 400.0; } else if (height < 260) { input.VideoBitRate = 1000.0; } else if (height < 400) { input.VideoBitRate = 2000.0; } else if (height < 800) { input.VideoBitRate = 5000.0; } else { input.VideoBitRate = 8000.0; } } if (input.AudioBitRate == 0.0) { input.AudioBitRate = 128.0; } string str = string.Format("-threads {0} -y -b {1} -ab {2}", treadCount.ToString(), input.VideoBitRate.ToString() + "k", input.AudioBitRate.ToString() + "k"); this.tempEncodedVideo = new EncodedVideo(); this.tempEncodedVideo.EncodedVideoPath = outputFile; this.tempCaller = caller; this.tempVideoFile = input; this.Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, str, outputFile); this.RunProcessAsync(this.Params); }
public void EncodeVideoAsync(VideoFile input, string encodingCommand, string outputFile, Control caller, int threadCount) { if (!input.infoGathered) { this.GetVideoInfo(input); } this.tempEncodedVideo = new EncodedVideo(); this.tempEncodedVideo.EncodedVideoPath = outputFile; this.tempCaller = caller; this.tempVideoFile = input; if (threadCount.Equals(1)) { this.Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); } else { this.Params = string.Format("-i \"{0}\" -threads {1} {2} \"{3}\"", new object[] { input.Path, threadCount.ToString(), encodingCommand, outputFile }); } this.RunProcessAsync(this.Params); }
/// <summary> /// Async for WinForms where secure threading is necessary, pass the control that will be used as Invoker /// This method uses output filename to detect resulting type, same resolution as source and the same bitrate as source /// </summary> /// <param name="input"></param> /// <param name="encodingCommand"></param> /// <param name="outputFile"></param> /// <param name="caller">The WinForm that makes the call</param> public void EncodeVideoAsyncAutoCommand(VideoFile input, string outputFile, System.Windows.Forms.Control caller, int treadCount) { //Gather info if (!input.infoGathered) { GetVideoInfo(input); } //If input video bitrate 0, then the correct video bitrate has not been detected, generate a value if (input.VideoBitRate == 0) { //Use video height, guestimations, tweak these at ur own will int h = input.Height; if (h < 180) input.VideoBitRate = 400; else if (h < 260) input.VideoBitRate = 1000; else if (h < 400) input.VideoBitRate = 2000; else if (h < 800) input.VideoBitRate = 5000; else input.VideoBitRate = 8000; } //If input audio bitrate is 0, then the correct audio bitrate has not been detected, set it to 128k if (input.AudioBitRate == 0) input.AudioBitRate = 128; //Build encoding command string encodingCommand = String.Format("-threads {0} -y -b {1} -ab {2}", treadCount.ToString(), input.VideoBitRate.ToString() + "k", input.AudioBitRate.ToString() + "k"); //Create new encoded video tempEncodedVideo = new EncodedVideo(); tempEncodedVideo.EncodedVideoPath = outputFile; //Set caller tempCaller = caller; //Set input tempVideoFile = input; //Create parameters Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); //Execute ffmpeg async RunProcessAsync(Params); }
/// <summary> /// Async for WinForms where secure threading is necessary, pass the control that will be used as Invoker /// </summary> /// <param name="input"></param> /// <param name="encodingCommand"></param> /// <param name="outputFile"></param> /// <param name="caller"></param> public void EncodeVideoAsync(VideoFile input, string encodingCommand, string outputFile, System.Windows.Forms.Control caller, int threadCount) { //Gather info if (!input.infoGathered) { GetVideoInfo(input); } //Create new encoded video tempEncodedVideo = new EncodedVideo(); tempEncodedVideo.EncodedVideoPath = outputFile; //Set caller tempCaller = caller; //Set input tempVideoFile = input; //Create parameters if (threadCount.Equals(1)) Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); else Params = string.Format("-i \"{0}\" -threads {1} {2} \"{3}\"", input.Path, threadCount.ToString(), encodingCommand, outputFile); //Execute ffmpeg async RunProcessAsync(Params); }
/// <summary> /// Async for WinForms where secure threading is necessary, pass the control that will be used as Invoker /// This method uses output filename to detect resulting type, same resolution as source and the same bitrate as source /// </summary> /// <param name="input"></param> /// <param name="encodingCommand"></param> /// <param name="outputFile"></param> /// <param name="caller">The WinForm that makes the call</param> public void EncodeVideoAsyncAutoCommand(VideoFile input, string outputFile, System.Windows.Forms.Control caller, int treadCount) { //Gather info if (!input.infoGathered) { GetVideoInfo(input); } //If input video bitrate 0, then the correct video bitrate has not been detected, generate a value if (input.VideoBitRate == 0) { //Use video height, guestimations, tweak these at ur own will int h = input.Height; if (h < 180) { input.VideoBitRate = 400; } else if (h < 260) { input.VideoBitRate = 1000; } else if (h < 400) { input.VideoBitRate = 2000; } else if (h < 800) { input.VideoBitRate = 5000; } else { input.VideoBitRate = 8000; } } //If input audio bitrate is 0, then the correct audio bitrate has not been detected, set it to 128k if (input.AudioBitRate == 0) { input.AudioBitRate = 128; } //Build encoding command string encodingCommand = String.Format("-threads {0} -y -b {1} -ab {2}", treadCount.ToString(), input.VideoBitRate.ToString() + "k", input.AudioBitRate.ToString() + "k"); //Create new encoded video tempEncodedVideo = new EncodedVideo(); tempEncodedVideo.EncodedVideoPath = outputFile; //Set caller tempCaller = caller; //Set input tempVideoFile = input; //Create parameters Params = string.Format("-i \"{0}\" {1} \"{2}\"", input.Path, encodingCommand, outputFile); //Execute ffmpeg async RunProcessAsync(Params); }