private void makeVideo(object _param) { isNowVideoSaving = true; photoThreadsCounter++; VideoParameters param = (VideoParameters)_param; Accord.Video.VFW.AVIWriter wr; wr = new AVIWriter(); wr.FrameRate = Convert.ToInt32(param.FPS); wr.Open(param.path, 2 * param.halfWidth, 2 * param.halfHeight); int frameCount = param.movie.frameCount(); for (int i = 0; i < frameCount; i++) { wr.AddFrame(param.movie[i].getFrame(param.halfWidth, param.halfHeight, grid)); Console.WriteLine("Frame {0} out of {1} is done!", i + 1, frameCount); statusFrames = String.Format("{0}/{1}", i + 1, frameCount); } wr.Close(); photoThreadsCounter--; isNowVideoSaving = false; statusFrames = ""; }
public override string GetArguments(string inputFileName, string outputFileName) { VideoParameters parms = VideoParameterOracle.GetParameters(inputFileName); if (parms == null) { return(GetSimpleArguments(inputFileName, outputFileName)); } else { StringBuilder paramsBuilder = new StringBuilder(); StringWriter paramsWriter = new StringWriter(paramsBuilder); if (parms.Height.HasValue && parms.Width.HasValue) { paramsWriter.Write("-x {0} -y {1} ", parms.Width, parms.Height); } if (parms.VideoBitrate.HasValue && parms.AudioBitrate.HasValue) { paramsWriter.Write("-V {0} -A {1} --two-pass ", parms.VideoBitrate, parms.AudioBitrate); } else { paramsWriter.Write("--videoquality 8 --audioquality 6 "); } paramsWriter.Close(); return(string.Format( "\"{0}\" -o \"{1}\" {2} --frontend", inputFileName, outputFileName, paramsBuilder.ToString())); } }
private void makeVideoClick() { if (isNowVideoSaving) { MessageBox.Show("One video rendering in progress. Please wait."); return; } if (sfdVideo.ShowDialog() != DialogResult.OK) { return; } var p = new VideoParameters(); p.halfWidth = videoWidth / 2; p.halfHeight = videoHeight / 2; p.path = sfdVideo.FileName; p.FPS = this.FPS; p.movie = movie; Thread t = new Thread(makeVideo); t.Start(p); }
public Form3() { InitializeComponent(); _capture = new Capture(Parameters.CaptureID); //create a camera captue for (int i = 2; i >= 0; i--) { _faceViewers[i] = new ImageBox(); //create an image viewer perspectivePnl.Controls.Add(_faceViewers[i]); _faceViewers[i].Dock = DockStyle.Left; _faceViewers[i].Width = size; } _processViewer = new ImageBox(); //create an image viewer pnl.Panel2.Controls.Add(_processViewer); pnl.Panel2.Controls.SetChildIndex(_processViewer, 0); _processViewer.Dock = DockStyle.Fill; _processViewer.Height = _capture.Height; if (File.Exists("parameters.xml")) { var serializer = new XmlSerializer(typeof(VideoParameters)); using (var reader = new StreamReader("parameters.xml")) { this.Parameters = (VideoParameters)serializer.Deserialize(reader); } } grid.SelectedObject = Parameters; }
/// <summary> /// Init the context and intern data. /// </summary> /// <param name="parameters">Video parameters unique to a media.</param> public virtual void Init(VideoParameters parameters) { frame.width = parameters.camera_width; frame.height = parameters.camera_height; frame.raw_data = new IntPtr(); frame.flip_mode = parameters.flip_mode; pixels = new Color32[parameters.camera_width * parameters.camera_height]; }
public DesktopTransportExecutor() { //get|width|height|showModel _commandText = new string[] { "get" }; ShowModel = ShowModels.FollowMouse; defaultVideoParameters = new VideoParameters() { Width = 800, Height = 480, Quality = 30L }; }
protected virtual void Start() { tracking = GetComponent <SingleThread>(); parameters = tracking.Parameters; if (parameters.log_datas) { LogsData.Instance.InitTargetErrorHeader(tracking.MaxTargets); } camera_table = Camera.main; }
public override void Init(VideoParameters parameters) { //Need special objects, watchout for rename. _cam = GameObject.Find("CamTable").GetComponent <Camera>(); _render_texture = Resources.Load("CameraTarget", typeof(RenderTexture)) as RenderTexture; Debug.Assert(_render_texture != null); Debug.Assert(_cam != null); base.Init(parameters); _cam.targetTexture = _render_texture; }
public override void Init(VideoParameters parameters) { if (File.Exists(parameters.file_path_video)) { _video = CARDSVideoPlugin.CreateVideoContextWrapped(parameters.file_path_video, parameters.camera_width, parameters.camera_height); Debug.Log("Open video " + parameters.file_path_video); } else { throw new Exception("File not exists " + Path.GetFullPath(parameters.file_path_video)); } base.Init(parameters); }
/// <summary> /// Obtain size argument for FFMPEG, in -s WIDTHxHEIGHT format. /// If either dimension of the input video is larger than target /// size, this will resize it to fit into the target size. /// Otherwise will return a blank string. /// </summary> /// <param name="inputFileName"></param> /// <param name="targetSize"></param> /// <returns></returns> protected string GetSizeArgument(string inputFileName, VideoSize targetSize) { VideoParameters parms = VideoParameterOracle.GetParameters(inputFileName); VideoSize size = parms == null ? null : parms.VideoSize; string sizeArg = ""; if (size != null && size.CompareTo(targetSize) > 0) { float widthRatio = (float)size.Width / targetSize.Width; float heightRatio = (float)size.Height / targetSize.Height; float ratio = Math.Max(widthRatio, heightRatio); sizeArg = string.Format("-s {0}x{1}", RoundEven((int)(size.Width / ratio)), RoundEven((int)(size.Height / ratio))); } return(sizeArg); }
public override void Init(VideoParameters parameters) { _cam_texture = new WebCamTexture { requestedFPS = parameters.requested_camera_fps, requestedWidth = parameters.camera_width, requestedHeight = parameters.camera_height }; WebCamDevice[] devices = WebCamTexture.devices; if (devices.Length > 0) { _cam_texture.deviceName = devices[parameters.device_index].name; _cam_texture.Play(); parameters.requested_camera_fps = (int)_cam_texture.requestedFPS; parameters.camera_width = _cam_texture.width; parameters.camera_height = _cam_texture.height; base.Init(parameters); } }
public IRequest Marshall(CreatePresetRequest createPresetRequest) { IRequest request = new DefaultRequest(createPresetRequest, "AmazonElasticTranscoder"); string target = "EtsCustomerService.CreatePreset"; request.Headers["X-Amz-Target"] = target; request.Headers["Content-Type"] = "application/x-amz-json-1.0"; request.HttpMethod = "POST"; string uriResourcePath = "2012-09-25/presets"; if (uriResourcePath.Contains("?")) { string queryString = uriResourcePath.Substring(uriResourcePath.IndexOf("?") + 1); uriResourcePath = uriResourcePath.Substring(0, uriResourcePath.IndexOf("?")); foreach (string s in queryString.Split('&', ';')) { string[] nameValuePair = s.Split('='); if (nameValuePair.Length == 2 && nameValuePair[1].Length > 0) { request.Parameters.Add(nameValuePair[0], nameValuePair[1]); } else { request.Parameters.Add(nameValuePair[0], null); } } } request.ResourcePath = uriResourcePath; using (StringWriter stringWriter = new StringWriter()) { JsonWriter writer = new JsonWriter(stringWriter); writer.WriteObjectStart(); if (createPresetRequest != null && createPresetRequest.IsSetName()) { writer.WritePropertyName("Name"); writer.Write(createPresetRequest.Name); } if (createPresetRequest != null && createPresetRequest.IsSetDescription()) { writer.WritePropertyName("Description"); writer.Write(createPresetRequest.Description); } if (createPresetRequest != null && createPresetRequest.IsSetContainer()) { writer.WritePropertyName("Container"); writer.Write(createPresetRequest.Container); } if (createPresetRequest != null) { VideoParameters video = createPresetRequest.Video; if (video != null) { writer.WritePropertyName("Video"); writer.WriteObjectStart(); if (video != null && video.IsSetCodec()) { writer.WritePropertyName("Codec"); writer.Write(video.Codec); } if (video != null) { if (video.CodecOptions != null && video.CodecOptions.Count > 0) { writer.WritePropertyName("CodecOptions"); writer.WriteObjectStart(); foreach (string videoCodecOptionsKey in video.CodecOptions.Keys) { string codecOptionsListValue; bool codecOptionsListValueHasValue = video.CodecOptions.TryGetValue(videoCodecOptionsKey, out codecOptionsListValue); writer.WritePropertyName(videoCodecOptionsKey); writer.Write(codecOptionsListValue); } writer.WriteObjectEnd(); } } if (video != null && video.IsSetKeyframesMaxDist()) { writer.WritePropertyName("KeyframesMaxDist"); writer.Write(video.KeyframesMaxDist); } if (video != null && video.IsSetFixedGOP()) { writer.WritePropertyName("FixedGOP"); writer.Write(video.FixedGOP); } if (video != null && video.IsSetBitRate()) { writer.WritePropertyName("BitRate"); writer.Write(video.BitRate); } if (video != null && video.IsSetFrameRate()) { writer.WritePropertyName("FrameRate"); writer.Write(video.FrameRate); } if (video != null && video.IsSetResolution()) { writer.WritePropertyName("Resolution"); writer.Write(video.Resolution); } if (video != null && video.IsSetAspectRatio()) { writer.WritePropertyName("AspectRatio"); writer.Write(video.AspectRatio); } if (video != null && video.IsSetMaxWidth()) { writer.WritePropertyName("MaxWidth"); writer.Write(video.MaxWidth); } if (video != null && video.IsSetMaxHeight()) { writer.WritePropertyName("MaxHeight"); writer.Write(video.MaxHeight); } if (video != null && video.IsSetDisplayAspectRatio()) { writer.WritePropertyName("DisplayAspectRatio"); writer.Write(video.DisplayAspectRatio); } if (video != null && video.IsSetSizingPolicy()) { writer.WritePropertyName("SizingPolicy"); writer.Write(video.SizingPolicy); } if (video != null && video.IsSetPaddingPolicy()) { writer.WritePropertyName("PaddingPolicy"); writer.Write(video.PaddingPolicy); } writer.WriteObjectEnd(); } } if (createPresetRequest != null) { AudioParameters audio = createPresetRequest.Audio; if (audio != null) { writer.WritePropertyName("Audio"); writer.WriteObjectStart(); if (audio != null && audio.IsSetCodec()) { writer.WritePropertyName("Codec"); writer.Write(audio.Codec); } if (audio != null && audio.IsSetSampleRate()) { writer.WritePropertyName("SampleRate"); writer.Write(audio.SampleRate); } if (audio != null && audio.IsSetBitRate()) { writer.WritePropertyName("BitRate"); writer.Write(audio.BitRate); } if (audio != null && audio.IsSetChannels()) { writer.WritePropertyName("Channels"); writer.Write(audio.Channels); } writer.WriteObjectEnd(); } } if (createPresetRequest != null) { Thumbnails thumbnails = createPresetRequest.Thumbnails; if (thumbnails != null) { writer.WritePropertyName("Thumbnails"); writer.WriteObjectStart(); if (thumbnails != null && thumbnails.IsSetFormat()) { writer.WritePropertyName("Format"); writer.Write(thumbnails.Format); } if (thumbnails != null && thumbnails.IsSetInterval()) { writer.WritePropertyName("Interval"); writer.Write(thumbnails.Interval); } if (thumbnails != null && thumbnails.IsSetResolution()) { writer.WritePropertyName("Resolution"); writer.Write(thumbnails.Resolution); } if (thumbnails != null && thumbnails.IsSetAspectRatio()) { writer.WritePropertyName("AspectRatio"); writer.Write(thumbnails.AspectRatio); } if (thumbnails != null && thumbnails.IsSetMaxWidth()) { writer.WritePropertyName("MaxWidth"); writer.Write(thumbnails.MaxWidth); } if (thumbnails != null && thumbnails.IsSetMaxHeight()) { writer.WritePropertyName("MaxHeight"); writer.Write(thumbnails.MaxHeight); } if (thumbnails != null && thumbnails.IsSetSizingPolicy()) { writer.WritePropertyName("SizingPolicy"); writer.Write(thumbnails.SizingPolicy); } if (thumbnails != null && thumbnails.IsSetPaddingPolicy()) { writer.WritePropertyName("PaddingPolicy"); writer.Write(thumbnails.PaddingPolicy); } writer.WriteObjectEnd(); } } writer.WriteObjectEnd(); string snippet = stringWriter.ToString(); request.Content = System.Text.Encoding.UTF8.GetBytes(snippet); } return(request); }
public void Excute(AsyncParameters parameters, string cmd) { try { string[] parms = cmd.Split('|'); if (parms != null && parms.Length > 1) { VideoParameters = new VideoParameters(); foreach (string p in parms) { string prm = p.ToLower(); if (prm == "followmouse") { ShowModel = ShowModels.FollowMouse; } else if (prm == "fullscreen") { ShowModel = ShowModels.FullScreen; } else if (prm[prm.Length - 1] == 'w') { VideoParameters.Width = int.Parse(prm.Substring(0, prm.Length - 1)); } else if (prm[prm.Length - 1] == 'h') { VideoParameters.Height = int.Parse(prm.Substring(0, prm.Length - 1)); } else if (prm[prm.Length - 1] == 'q') { VideoParameters.Quality = long.Parse(prm.Substring(0, prm.Length - 1)); } } } } catch { } VideoParameters v; if (VideoParameters == null || VideoParameters.Width == 0 || VideoParameters.Height == 0) { v = defaultVideoParameters; } else { v = VideoParameters; } try { Screenshot ss = new Screenshot(); Image img = null; if (ShowModel == ShowModels.FollowMouse) { img = ss.GetRectangleScreenshot(v); } else { img = ss.GetFullScreenImage(v); } parameters.Data = ImageProcessing.CompressedImageQuality(img, v.Quality); img.Dispose(); //Console.WriteLine(parameters.Data.Length / 1024); parameters.Client.BeginSend(parameters.Data, 0, parameters.Data.Length, 0, new AsyncCallback(EndSend), parameters); } catch (Exception e) { Console.WriteLine(e.Message + e.Source + e.StackTrace); } }
public bool setFrameDelimiter(VideoParameters videoParameters, byte[] frameDelimiter) { videoParameters.frameDelimiter = frameDelimiter; return true; }
public byte[] getFrameDelimiter(VideoParameters videoParameters) { return videoParameters.frameDelimiter; }
public IRequest Marshall(CreatePresetRequest createPresetRequest) { IRequest request = new DefaultRequest(createPresetRequest, "AmazonElasticTranscoder"); string target = "EtsCustomerService.CreatePreset"; request.Headers["X-Amz-Target"] = target; request.Headers["Content-Type"] = "application/x-amz-json-1.0"; request.HttpMethod = "POST"; string uriResourcePath = "2012-09-25/presets"; request.ResourcePath = uriResourcePath; using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { JsonWriter writer = new JsonWriter(stringWriter); writer.WriteObjectStart(); if (createPresetRequest != null && createPresetRequest.IsSetName()) { writer.WritePropertyName("Name"); writer.Write(createPresetRequest.Name); } if (createPresetRequest != null && createPresetRequest.IsSetDescription()) { writer.WritePropertyName("Description"); writer.Write(createPresetRequest.Description); } if (createPresetRequest != null && createPresetRequest.IsSetContainer()) { writer.WritePropertyName("Container"); writer.Write(createPresetRequest.Container); } if (createPresetRequest != null) { VideoParameters video = createPresetRequest.Video; if (video != null) { writer.WritePropertyName("Video"); writer.WriteObjectStart(); if (video != null && video.IsSetCodec()) { writer.WritePropertyName("Codec"); writer.Write(video.Codec); } if (video != null) { if (video.CodecOptions != null && video.CodecOptions.Count > 0) { writer.WritePropertyName("CodecOptions"); writer.WriteObjectStart(); foreach (string videoCodecOptionsKey in video.CodecOptions.Keys) { string codecOptionsListValue; bool codecOptionsListValueHasValue = video.CodecOptions.TryGetValue(videoCodecOptionsKey, out codecOptionsListValue); writer.WritePropertyName(videoCodecOptionsKey); writer.Write(codecOptionsListValue); } writer.WriteObjectEnd(); } } if (video != null && video.IsSetKeyframesMaxDist()) { writer.WritePropertyName("KeyframesMaxDist"); writer.Write(video.KeyframesMaxDist); } if (video != null && video.IsSetFixedGOP()) { writer.WritePropertyName("FixedGOP"); writer.Write(video.FixedGOP); } if (video != null && video.IsSetBitRate()) { writer.WritePropertyName("BitRate"); writer.Write(video.BitRate); } if (video != null && video.IsSetFrameRate()) { writer.WritePropertyName("FrameRate"); writer.Write(video.FrameRate); } if (video != null && video.IsSetMaxFrameRate()) { writer.WritePropertyName("MaxFrameRate"); writer.Write(video.MaxFrameRate); } if (video != null && video.IsSetResolution()) { writer.WritePropertyName("Resolution"); writer.Write(video.Resolution); } if (video != null && video.IsSetAspectRatio()) { writer.WritePropertyName("AspectRatio"); writer.Write(video.AspectRatio); } if (video != null && video.IsSetMaxWidth()) { writer.WritePropertyName("MaxWidth"); writer.Write(video.MaxWidth); } if (video != null && video.IsSetMaxHeight()) { writer.WritePropertyName("MaxHeight"); writer.Write(video.MaxHeight); } if (video != null && video.IsSetDisplayAspectRatio()) { writer.WritePropertyName("DisplayAspectRatio"); writer.Write(video.DisplayAspectRatio); } if (video != null && video.IsSetSizingPolicy()) { writer.WritePropertyName("SizingPolicy"); writer.Write(video.SizingPolicy); } if (video != null && video.IsSetPaddingPolicy()) { writer.WritePropertyName("PaddingPolicy"); writer.Write(video.PaddingPolicy); } if (video != null && video.Watermarks != null && video.Watermarks.Count > 0) { List <PresetWatermark> watermarksList = video.Watermarks; writer.WritePropertyName("Watermarks"); writer.WriteArrayStart(); foreach (PresetWatermark watermarksListValue in watermarksList) { writer.WriteObjectStart(); if (watermarksListValue != null && watermarksListValue.IsSetId()) { writer.WritePropertyName("Id"); writer.Write(watermarksListValue.Id); } if (watermarksListValue != null && watermarksListValue.IsSetMaxWidth()) { writer.WritePropertyName("MaxWidth"); writer.Write(watermarksListValue.MaxWidth); } if (watermarksListValue != null && watermarksListValue.IsSetMaxHeight()) { writer.WritePropertyName("MaxHeight"); writer.Write(watermarksListValue.MaxHeight); } if (watermarksListValue != null && watermarksListValue.IsSetSizingPolicy()) { writer.WritePropertyName("SizingPolicy"); writer.Write(watermarksListValue.SizingPolicy); } if (watermarksListValue != null && watermarksListValue.IsSetHorizontalAlign()) { writer.WritePropertyName("HorizontalAlign"); writer.Write(watermarksListValue.HorizontalAlign); } if (watermarksListValue != null && watermarksListValue.IsSetHorizontalOffset()) { writer.WritePropertyName("HorizontalOffset"); writer.Write(watermarksListValue.HorizontalOffset); } if (watermarksListValue != null && watermarksListValue.IsSetVerticalAlign()) { writer.WritePropertyName("VerticalAlign"); writer.Write(watermarksListValue.VerticalAlign); } if (watermarksListValue != null && watermarksListValue.IsSetVerticalOffset()) { writer.WritePropertyName("VerticalOffset"); writer.Write(watermarksListValue.VerticalOffset); } if (watermarksListValue != null && watermarksListValue.IsSetOpacity()) { writer.WritePropertyName("Opacity"); writer.Write(watermarksListValue.Opacity); } if (watermarksListValue != null && watermarksListValue.IsSetTarget()) { writer.WritePropertyName("Target"); writer.Write(watermarksListValue.Target); } writer.WriteObjectEnd(); } writer.WriteArrayEnd(); } writer.WriteObjectEnd(); } } if (createPresetRequest != null) { AudioParameters audio = createPresetRequest.Audio; if (audio != null) { writer.WritePropertyName("Audio"); writer.WriteObjectStart(); if (audio != null && audio.IsSetCodec()) { writer.WritePropertyName("Codec"); writer.Write(audio.Codec); } if (audio != null && audio.IsSetSampleRate()) { writer.WritePropertyName("SampleRate"); writer.Write(audio.SampleRate); } if (audio != null && audio.IsSetBitRate()) { writer.WritePropertyName("BitRate"); writer.Write(audio.BitRate); } if (audio != null && audio.IsSetChannels()) { writer.WritePropertyName("Channels"); writer.Write(audio.Channels); } if (audio != null) { AudioCodecOptions codecOptions = audio.CodecOptions; if (codecOptions != null) { writer.WritePropertyName("CodecOptions"); writer.WriteObjectStart(); if (codecOptions != null && codecOptions.IsSetProfile()) { writer.WritePropertyName("Profile"); writer.Write(codecOptions.Profile); } writer.WriteObjectEnd(); } } writer.WriteObjectEnd(); } } if (createPresetRequest != null) { Thumbnails thumbnails = createPresetRequest.Thumbnails; if (thumbnails != null) { writer.WritePropertyName("Thumbnails"); writer.WriteObjectStart(); if (thumbnails != null && thumbnails.IsSetFormat()) { writer.WritePropertyName("Format"); writer.Write(thumbnails.Format); } if (thumbnails != null && thumbnails.IsSetInterval()) { writer.WritePropertyName("Interval"); writer.Write(thumbnails.Interval); } if (thumbnails != null && thumbnails.IsSetResolution()) { writer.WritePropertyName("Resolution"); writer.Write(thumbnails.Resolution); } if (thumbnails != null && thumbnails.IsSetAspectRatio()) { writer.WritePropertyName("AspectRatio"); writer.Write(thumbnails.AspectRatio); } if (thumbnails != null && thumbnails.IsSetMaxWidth()) { writer.WritePropertyName("MaxWidth"); writer.Write(thumbnails.MaxWidth); } if (thumbnails != null && thumbnails.IsSetMaxHeight()) { writer.WritePropertyName("MaxHeight"); writer.Write(thumbnails.MaxHeight); } if (thumbnails != null && thumbnails.IsSetSizingPolicy()) { writer.WritePropertyName("SizingPolicy"); writer.Write(thumbnails.SizingPolicy); } if (thumbnails != null && thumbnails.IsSetPaddingPolicy()) { writer.WritePropertyName("PaddingPolicy"); writer.Write(thumbnails.PaddingPolicy); } writer.WriteObjectEnd(); } } writer.WriteObjectEnd(); string snippet = stringWriter.ToString(); request.Content = System.Text.Encoding.UTF8.GetBytes(snippet); } return(request); }