Exemplo n.º 1
0
		/// <summary>
		/// Asynchronously streams a windows screen and audio capture to a specified IP-Address.
		/// </summary>
		/// <returns>The windows screen to ip async.</returns>
		/// <param name="videoDeviceName">Video device name.</param>
		/// <param name="audioDeviceName">Audio device name.</param>
		/// <param name="ip">IP-Address.</param>
		/// <param name="mode">Streaming mode.</param>
		/// <param name="frameRate">Desired frame rate.</param>
		/// <param name="quality">Quality of compression.</param>
		public async Task<bool> StreamWindowsScreenToIpAsync (string videoDeviceName, string audioDeviceName, string ip, string port, VideoCodec vcodec, AudioCodec acodec, StreamingMode mode, int frameRate, Resolution outputSize, string videoExtras, int quality = 20) 
		{
			// TODO: -b for bitrate
			string input = string.Format (
				"-f dshow  -i video=\"{0}\":audio=\"{1}\" -r {2} -async 1 -vcodec {3} {4} -q {5} -s {6} -maxrate 750k -bufsize 3000k -acodec {7} -ab 128k",
				videoDeviceName, 
				audioDeviceName, 
				frameRate.ToString(), 
				FFmpegManager.GetCodecName(vcodec), 
				videoExtras,
				quality.ToString(),
				outputSize,
				FFmpegManager.GetCodecName(acodec)		
			);
			string output = string.Format (
				"-f mpegts udp://{0}:{1}?pkt_size=188?buffer_size=10000000?fifo_size=100000", 
				ip, 
				port
			);

			string args = input + " " + output;

			try {
				FFmpegProcess = FFmpegManager.GetFFmpegProcess(args);
			}
			catch(FileNotFoundException e) {
				throw new FileNotFoundException (e.Message, e);
			}

			FFmpegProcess.Start ();
			await Task.Run(() => FFmpegProcess.WaitForExit ());
			return true;
		}
Exemplo n.º 2
0
        /// <summary>
        /// Format a video codec argument for ffmpeg.
        /// </summary>
        public static string formatVideoCodecArg(VideoCodec videoCodec)
        {
            string videoCodecArg = "";
            string command       = "-codec:v ";

            switch (videoCodec)
            {
            case VideoCodec.COPY:
                videoCodecArg = command + "copy";
                break;

            case VideoCodec.h264:
                videoCodecArg = command + "libx264";
                break;

            case VideoCodec.MPEG4:
                videoCodecArg = command + " mpeg4";
                break;

            default:
                videoCodecArg = "";
                break;
            }

            return(videoCodecArg);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Save a stream of image frames as an AVI video file.
        /// </summary>
        /// <param name="frames">Ordered list of frames at 30 fps.</param>
        /// <param name="width">Frame width.</param>
        /// <param name="height">Frame height.</param>
        /// <param name="file">Output filename.</param>
        public static void SaveAsAvi(List <Color[]> frames, int width, int height, string file)
        {
            if (frames.Count == 0)
            {
                return;
            }

            using (VideoWriter writer = new VideoWriter(file, new Size(width, height),
                                                        30, true, VideoCodec.FromName("MJPG"))) {
                writer.Open();

                foreach (Color[] frame in frames)
                {
                    Bgr <byte>[,] bitmap = new Bgr <byte> [height, width];

                    int h = 0;
                    for (int k = 0; k < height; k++)
                    {
                        for (int i = 0; i < width; i++)
                        {
                            bitmap[k, i] = new Bgr <byte>(frame[h].B, frame[h].G, frame[h].R);
                            h++;
                        }
                    }

                    writer.Write(bitmap.Lock());
                }

                writer.Close();
            }
        }
Exemplo n.º 4
0
        internal static VideoMimeType GetCodecMimeType(VideoCodec videoCodec)
        {
            switch (videoCodec)
            {
            case VideoCodec.H263:
                return(VideoMimeType.H263);

            case VideoCodec.H264:
                return(VideoMimeType.H264);

            case VideoCodec.H265:
                return(VideoMimeType.Hevc);

            case VideoCodec.MPEG2:
                return(VideoMimeType.Mpeg2);

            case VideoCodec.MPEG4:
                return(VideoMimeType.Mpeg4);

            case VideoCodec.VP8:
                return(VideoMimeType.Vp8);

            case VideoCodec.VP9:
                return(VideoMimeType.Vp9);

            case VideoCodec.WMV3:
                return(VideoMimeType.Wmv3);

            case VideoCodec.WMV1:
            case VideoCodec.WMV2:
            default:
                throw new ArgumentOutOfRangeException(
                          $"No mapping from Juvo video codec {videoCodec} to ESPlayer aideo codec");
            }
        }
 public VideoOptions()
 {
     InputPath  = string.Empty;
     OutputPath = string.Empty;
     FileName   = string.Empty;
     FileFormat = string.Empty;
     Codec      = VideoCodec.WMV2;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VideoEncoderSettings"/> class with default video settings values.
 /// </summary>
 /// <param name="width">The video frame width.</param>
 /// <param name="height">The video frame height.</param>
 /// <param name="framerate">The video frames per seconds (fps) value.</param>
 /// <param name="codec">The video encoder.</param>
 public VideoEncoderSettings(int width, int height, int framerate = 30, VideoCodec codec = VideoCodec.Default)
 {
     VideoWidth   = width;
     VideoHeight  = height;
     Framerate    = framerate;
     Codec        = codec;
     CodecOptions = new Dictionary <string, string>();
 }
Exemplo n.º 7
0
        private void cboVideoCodec_SelectedIndexChanged(object sender, EventArgs e)
        {
            VideoCodec codec = cboVideoCodec.GetEnumValue <VideoCodec>();
            bool       hasCompressionLevel = (codec == VideoCodec.CSCD || codec == VideoCodec.ZMBV);

            lblCompressionLevel.Visible = hasCompressionLevel;
            tlpCompressionLevel.Visible = hasCompressionLevel;
        }
Exemplo n.º 8
0
 private void ClearVideo()
 {
     if (VideoCodecId == VideoCodec.H264)
     {
         Avc.Clear();
     }
     VideoCodecId = VideoCodec.PassThrough;
 }
Exemplo n.º 9
0
 public VideoData(string link, string qualitydesciption, VideoCodec codec, bool audioOnly = false, bool videoOnly = false)
 {
     Link = link;
     Qualitydesciption = qualitydesciption;
     Codec             = codec;
     AudioOnly         = audioOnly;
     VideoOnly         = videoOnly;
 }
Exemplo n.º 10
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            VideoCodec codec       = cboVideoCodec.GetEnumValue <VideoCodec>();
            string     defaultFile = Path.Combine(ConfigManager.AviFolder, InteropEmu.GetRomInfo().GetRomName() + (codec == VideoCodec.GIF ? ".gif" : ".avi"));

            txtFilename.Text = defaultFile;
        }
Exemplo n.º 11
0
            public static BuiltInVideoCodecSettings New(VideoCodec codec, string description)
            {
                var info = new BuiltInVideoCodecSettings();

                info.Codec       = codec;
                info.Description = description;

                return(info);
            }
Exemplo n.º 12
0
        /// <summary>
        /// Creates an object of RecordingSettings to use with RecordingLib. This object holds all important information required for a recording process.
        /// </summary>
        /// <param name="res">Describes the resolution of the output video</param>
        /// <param name="fps">Describes the frames per second of the output video</param>
        /// <param name="codec">Describes the output video format.</param>
        /// <param name="bitrate">Describes the bitrate of the output video. In Kbps</param>
        /// <param name="path">Describes the output path</param>
        /// <param name="interval">Describes the interval between frame shots (In Milliseconds)</param>
        ///


        public RecordingSettings(Resolution res, int fps, /*VideoCodec codec,*/ int bitrate, string path, int interval = 0)
        {
            this._res      = res;
            this._fps      = fps;
            this._codec    = VideoCodec.MPEG4;
            this._bitrate  = (int)bitrate; //convert to kbps
            this._path     = path;
            this._interval = interval;     //convert to milliseconds
        }
Exemplo n.º 13
0
        public static string VideoCodecAsString(VideoCodec codec)
        {
            string videoCodec;

            switch (codec)
            {
            case VideoCodec.H264:
                videoCodec = "libx264";
                break;

            case VideoCodec.H264_amd:
                videoCodec = "h264_amf";
                break;

            case VideoCodec.H264_nvenc:
                videoCodec = "h264_nvenc";
                break;

            case VideoCodec.H264_intel_qsv:
                videoCodec = "h264_qsv";
                break;

            case VideoCodec.H265:
                videoCodec = "libx265";
                break;

            case VideoCodec.H265_nvenc:
                videoCodec = "hevc_nvenc";
                break;

            case VideoCodec.H265_amd:
                videoCodec = "hevc_amf";
                break;

            case VideoCodec.H265_intel_qsv:
                videoCodec = "hevc_qsv";
                break;

            case VideoCodec.VP8:
                videoCodec = "libvpx";
                break;

            case VideoCodec.VP9:
                videoCodec = "libvpx-vp9";
                break;

            case VideoCodec.Copy:
                videoCodec = "copy";
                break;

            default:
                videoCodec = "copy";
                break;
            }
            return(videoCodec);
        }
Exemplo n.º 14
0
        private void recordVideoBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // get only images from a chosen directory including subdirectories
            var ext = new List <string> {
                ".jpg", ".gif", ".png"
            };

            string[] photos = Directory.GetFiles(photoDirectory, "*.*",
                                                 SearchOption.AllDirectories).
                              Where(s => ext.Any(el => s.EndsWith(el, true, null))).
                              ToArray();

            // sort photos
            string [] sortedPhotos = SortPhotos(photos, sortingMethod);

            // get a corresponding video codec
            VideoCodec codec = GetVideoCodec(videoCodecName);

            // size of video frame
            int width  = 1100;
            int height = 800;

            writer.Open(videoOutputFile, width, height, 1, codec);

            int progress = 0;

            for (int i = 0; i < sortedPhotos.Length; i++)
            {
                string photoName = sortedPhotos[i];
                ProcessOnePhoto(
                    photoName,
                    width,
                    height,
                    slideDuration,
                    writer
                    );

                if (recordVideoBackgroundWorker.CancellationPending)
                {
                    writer.Close();
                    e.Cancel = true;
                    // delete video file
                    if (File.Exists(videoOutputFile))
                    {
                        File.Delete(videoOutputFile);
                    }
                    return;
                }

                // show progress
                progress += (int)(100 / photos.Length);
                recordVideoBackgroundWorker.ReportProgress(progress);
            }

            writer.Close();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Xamarin.iOS.Conference.WebRTC.IvfVideoCaptureProvider"/> class.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="codec">The codec.</param>
        public IvfVideoCaptureProvider(string path, VideoCodec codec)
        {
            if (!codec.Initialized)
            {
                throw new Exception("Codec must be initialized first (VideoCodec.Initialize).");
            }

            _Codec    = codec;
            _Recorder = new IvfVideoRecorder(path, _Codec.EncodingName, _Codec.ClockRate);
        }
Exemplo n.º 16
0
 public string GetEncoderProfile(VideoCodec codec, EncodingProfile profile)
 {
     if (Profiles.ContainsKey(codec))
     {
         string profileArg;
         Profiles[codec].TryGetValue(profile, out profileArg);
         return(profileArg);
     }
     return(null);
 }
Exemplo n.º 17
0
 public string GetEncoderPreset(VideoCodec codec, EncodingPreset preset)
 {
     if (Presets.ContainsKey(codec))
     {
         string presetArg;
         Presets[codec].TryGetValue(preset, out presetArg);
         return(presetArg);
     }
     return(null);
 }
Exemplo n.º 18
0
        protected virtual Codec GetVideoCodec(FFmpegConfig config,
                                              VideoStreamInfo sourceStream,
                                              VideoOutputStream outputStream)
        {
            VideoFormat format    = outputStream.Format;
            VideoCodec  codec     = config?.Video?.Codecs.GetValueOrDefault(format);
            string      codecName = GetVideoCodecName(format);
            X26xCodec   result    = format == VideoFormat.Hevc ? new X265Codec(codecName) : new X26xCodec(codecName);

            result.Preset = codec?.Preset;
            result.Crf    = outputStream.Quality;

            if (outputStream.DynamicRange == DynamicRange.High)
            {
                if (outputStream.Format != VideoFormat.Hevc)
                {
                    throw new NotSupportedException($"HDR is not supported with the video format {outputStream.Format}.");
                }

                var options = new List <Option>()
                {
                    new Option("colorprim", "bt2020"),
                    new Option("colormatrix", "bt2020nc"),
                    new Option("transfer", "smpte2084")
                };

                if (outputStream.CopyHdrMetadata)
                {
                    if (sourceStream.MasterDisplayProperties != null)
                    {
                        var properties = sourceStream.MasterDisplayProperties;
                        var value      = string.Format("\"G{0}B{1}R{2}WP{3}L({4},{5})\"",
                                                       properties.Green,
                                                       properties.Blue,
                                                       properties.Red,
                                                       properties.WhitePoint,
                                                       properties.Luminance.Max,
                                                       properties.Luminance.Min);

                        options.Add(new Option("master-display", value));
                    }

                    if (sourceStream.LightLevelProperties != null)
                    {
                        var properties = sourceStream.LightLevelProperties;

                        options.Add(new Option("max-cll", $"\"{properties.MaxCll},{properties.MaxFall}\""));
                    }
                }

                ((X265Codec)result).Options = options;
            }

            return(result);
        }
Exemplo n.º 19
0
 internal bool InitVideoH264(byte[] pSPS, byte[] pPPS)
 {
     ClearVideo();
     if (!Avc.Init(pSPS, pPPS))
     {
         ClearVideo();
         return(false);
     }
     VideoCodecId = VideoCodec.H264;
     return(true);
 }
Exemplo n.º 20
0
        internal static string Video(VideoCodec codec, int bitrate = 0)
        {
            var video = $"-codec:v {codec.ToString().ToLower()} ";

            if (bitrate > 0)
            {
                video += $"-b:v {bitrate}k ";
            }

            return(video);
        }
Exemplo n.º 21
0
 public static string GetCodecName(VideoCodec vc)
 {
     switch (vc) {
     case VideoCodec.x264:
         return "libx264";
     case VideoCodec.Mpeg4:
         return "mpeg4";
     default:
         return "";
     }
 }
Exemplo n.º 22
0
        public void LoadHdDemo(string fileName, VideoCodec videoCodec, int height, ColorSpace colorSpace, ChromaSubSampling chromaSubSampling)
        {
            _mediaInfoWrapper = new MediaInfoWrapper(fileName, _logger);
            _mediaInfoWrapper.MediaInfoNotloaded.Should().BeFalse("InfoWrapper should be loaded");
            _mediaInfoWrapper.HasVideo.Should().BeTrue("Video stream must be detected");
            var video = _mediaInfoWrapper.VideoStreams[0];

            video.Height.Should().Be(height);
            video.Codec.Should().Be(videoCodec);
            video.ColorSpace.Should().Be(colorSpace);
            video.SubSampling.Should().Be(chromaSubSampling);
        }
        /// <summary>
        ///
        /// </summary>
        protected override void EndShutdown()
        {
            VideoCodec.EndAllCalls();

            SetDefaultLevels();

            RunDefaultPresentRoute();

            CrestronEnvironment.Sleep(1000);

            RunRouteAction("roomOff");
        }
Exemplo n.º 24
0
        private void EncodingSettingsGUI(int platformIndex, MultiTargetSettingState multiState)
        {
            EditorGUI.showMixedValue = multiState.mixedCodec;
            EditorGUI.BeginChangeCheck();
            VideoCodec codec = (VideoCodec)EditorGUILayout.EnumPopup(s_Styles.codecContent, multiState.firstCodec);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                for (int i = 0; i < m_TargetSettings.GetLength(0); i++)
                {
                    if (m_TargetSettings[i, platformIndex].settings != null)
                    {
                        m_TargetSettings[i, platformIndex].settings.codec = codec;
                        m_ModifiedTargetSettings = true;
                    }
                }
            }

            EditorGUI.showMixedValue = multiState.mixedBitrateMode;
            EditorGUI.BeginChangeCheck();
            VideoBitrateMode bitrateMode = (VideoBitrateMode)EditorGUILayout.EnumPopup(s_Styles.bitrateContent, multiState.firstBitrateMode);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                for (int i = 0; i < m_TargetSettings.GetLength(0); i++)
                {
                    if (m_TargetSettings[i, platformIndex].settings != null)
                    {
                        m_TargetSettings[i, platformIndex].settings.bitrateMode = bitrateMode;
                        m_ModifiedTargetSettings = true;
                    }
                }
            }

            EditorGUI.showMixedValue = multiState.mixedSpatialQuality;
            EditorGUI.BeginChangeCheck();
            VideoSpatialQuality spatialQuality = (VideoSpatialQuality)EditorGUILayout.EnumPopup(s_Styles.spatialQualityContent, multiState.firstSpatialQuality);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                for (int i = 0; i < m_TargetSettings.GetLength(0); i++)
                {
                    if (m_TargetSettings[i, platformIndex].settings != null)
                    {
                        m_TargetSettings[i, platformIndex].settings.spatialQuality = spatialQuality;
                        m_ModifiedTargetSettings = true;
                    }
                }
            }
        }
Exemplo n.º 25
0
 //misc init helpers
 private static void SetVideoCodec()
 {
     if (DefaultCapture.Vidform == ScapVideoFormats.Default)
     {
         VidCodec = VideoCodec.Default;
         DefaultCapture.Vidext = ".avi";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.FLV1)
     {
         VidCodec = VideoCodec.FLV1;
         DefaultCapture.Vidext = ".flv";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.H263P)
     {
         VidCodec = VideoCodec.H263P;
         DefaultCapture.Vidext = ".avi";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.MPEG2)
     {
         VidCodec = VideoCodec.MPEG2;
         DefaultCapture.Vidext = ".avi";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.MPEG4)
     {
         VidCodec = VideoCodec.MPEG4;
         DefaultCapture.Vidext = ".avi";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.MSMPEG4v2)
     {
         VidCodec = VideoCodec.MSMPEG4v2;
         DefaultCapture.Vidext = ".avi";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.MSMPEG4v3)
     {
         VidCodec = VideoCodec.MSMPEG4v3;
         DefaultCapture.Vidext = ".avi";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.RAW)
     {
         VidCodec = VideoCodec.Raw;
         DefaultCapture.Vidext = ".avi";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.WMV1)
     {
         VidCodec = VideoCodec.WMV1;
         DefaultCapture.Vidext = ".wmv";
     }
     if (DefaultCapture.Vidform == ScapVideoFormats.WMV2)
     {
         VidCodec = VideoCodec.WMV2;
         DefaultCapture.Vidext = ".wmv";
     }
 }
Exemplo n.º 26
0
        public CmdConnect(byte[] payload)
        {
            int payloadLen = payload.Length;
            double result = 0;
            if (!ArrayUtil.AMF0Number(payload, posID, ref result))
                return;

            TransactionID = result;

            var posConnObjEnd = ArrayUtil.FindPattern(payload, objectEnd, 20);
            if (posConnObjEnd < 0)
                return;

            var connObjectData = ArrayUtil.Mid(payload, 20, posConnObjEnd - 20);

            connObject = new AMFObject(connObjectData);

            AudioCodecs = new Dictionary<AudioCodec, bool>();
            VideoCodecs = new Dictionary<VideoCodec, bool>();
            var audioCodecs = new AudioCodec[] {
                    AudioCodec.Raw,
                    AudioCodec.ADPCM,
                    AudioCodec.MP3,
                    AudioCodec.NotUsed1,
                    AudioCodec.NotUsed2,
                    AudioCodec.NellyMoser8KHz,
                    AudioCodec.NellyMoser44KHz,
                    AudioCodec.G711A,
                    AudioCodec.G711U,
                    AudioCodec.NellyMoser16KHz,
                    AudioCodec.AAC,
                    AudioCodec.Speex,
                    AudioCodec.All
                };
            var videoCodecs = new VideoCodec[] {
                    VideoCodec.Obsolete1,
                    VideoCodec.Obsolete2,
                    VideoCodec.FlashVideo,
                    VideoCodec.V1ScrSharing,
                    VideoCodec.VP6,
                    VideoCodec.VP6Alpha,
                    VideoCodec.HomeBrewV,
                    VideoCodec.H264,
                    VideoCodec.All
            };

            foreach( var codec in audioCodecs )
                AudioCodecs.Add( codec, false );

            foreach (var codec in videoCodecs)
                VideoCodecs.Add( codec, false);
        }
Exemplo n.º 27
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            string    deviceName = boxDevice.SelectedItem.ToString();
            string    path       = textPath.Text.Trim();
            int       width      = Convert.ToInt32(textWidth.Text.Trim());
            int       height     = Convert.ToInt32(textHeight.Text.Trim());
            int       frameRate  = Convert.ToInt32(textFrameRate.Text.Trim());
            int       bitRate    = Convert.ToInt32(textBitRate.Text.Trim());
            VideoType videoType  = (VideoType)Enum.Parse(typeof(VideoType), boxVideoType.SelectedItem.ToString());

            if (videoDevices == null || videoDevices.Count < 1)
            {
                return;
            }

            int selectedVideoDeviceIndex = -1;

            for (int i = 0; i < videoDevices.Count; i++)
            {
                if (deviceName == videoDevices[i].Name)
                {
                    selectedVideoDeviceIndex = i;
                    break;
                }
            }

            if (selectedVideoDeviceIndex < 0)
            {
                throw new Exception("video input device name not found!");
            }

            videoSource           = new VideoCaptureDevice(videoDevices[selectedVideoDeviceIndex].MonikerString);
            videoSource.NewFrame += videoNewFrame;
            videoSource.Start();

            VideoCodec videoCodec = GetVideoCode(videoType);

            path = string.Format("{0}.{1}", path, videoType);
            string dir = Path.GetDirectoryName(path);

            if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            videoWriter.Open(path, width, height, frameRate, videoCodec, bitRate);


            labelStatus.Text    = "录制中...";
            buttonStart.Enabled = false;
            buttonStop.Enabled  = true;
        }
Exemplo n.º 28
0
        public void StartRecording()
        {
            string filePathBase = Utils.GetFilePathBase(DateTime.Now, recorderPanel);

            VideoCodec codec   = dctCodecs[recorderPanel.Codec];
            int        bitrate = recorderPanel.Bitrate;

            bitrate *= 1024;                // b -> kb

            OpenVideoWriters(filePathBase, codec, bitrate);
            isRecording = true;
            RunRecording();
        }
Exemplo n.º 29
0
 public VideoFormat(uint fps, uint width, uint height, VideoCodec codec,
                    uint bpp = 0, uint bytes = 0, uint redMask = 0, uint greenMask = 0, uint blueMask = 0)
 {
     FPS       = fps;
     Width     = width;
     Height    = height;
     Codec     = codec;
     Bpp       = bpp;
     Bytes     = bytes;
     RedMask   = redMask;
     GreenMask = greenMask;
     BlueMask  = blueMask;
 }
        /// <summary>
        ///   Creates a new motion capture session
        /// </summary>
        /// <param name="codec">The Media Foundation codec instance</param>
        /// <param name="device">The video provider instance</param>
        internal MotionCaptureSession(VideoCodec codec, VideoCaptureDevice device)
        {
            this.codec  = codec;
            this.device = device;

            Log.Info("starting encoder thread");
            this.encodingThread = new Thread(ThreadStart)
            {
                Priority = ThreadPriority.BelowNormal
            };
            this.encodingThread.Start();
            Log.Debug($"encoder thread with ID {this.encodingThread.ManagedThreadId} has been started");
        }
Exemplo n.º 31
0
 public RecordSettings(string outputPath, Rectangle captureRectangle, int fps = 30, int interval = 500, VideoCodec codec = VideoCodec.MPEG4, int bitrate = 20, double?splitInterval = null, Action <TimeSpan> onFrameWritten = null, bool realtime = false)
 {
     OutputPath       = outputPath;
     CaptureRectangle = captureRectangle;
     OnFrameWritten   = onFrameWritten;
     Interval         = interval;
     Fps           = fps;
     Codec         = codec;
     Bitrate       = bitrate;
     SplitInterval = splitInterval;
     Private       = false;
     Realtime      = realtime;
 }
Exemplo n.º 32
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd   = new SaveFileDialog();
            VideoCodec     codec = cboVideoCodec.GetEnumValue <VideoCodec>();

            sfd.SetFilter(ResourceHelper.GetMessage(codec == VideoCodec.GIF ? "FilterGif" : "FilterAvi"));
            sfd.InitialDirectory = ConfigManager.AviFolder;
            sfd.FileName         = InteropEmu.GetRomInfo().GetRomName() + (codec == VideoCodec.GIF ? ".gif" : ".avi");
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                txtFilename.Text = sfd.FileName;
            }
        }
        /// <summary>
        /// Serializes the specified serializer.
        /// </summary>
        /// <param name="serializer">The serializer.</param>
        /// <returns>
        /// A serialized <see cref="IDictionary{String,Object}" />.
        /// </returns>
        public IDictionary <string, object> Serialize(JavaScriptSerializer serializer)
        {
            IDictionary <string, object> serialized = new Dictionary <string, object>();

            serialized["controllerType"]   = ControllerType.ToBrightcoveName();
            serialized["remoteUrl"]        = RemoteUrl;
            serialized["remoteStreamName"] = RemoteStreamName;
            serialized["size"]             = Size;
            serialized["videoDuration"]    = VideoDuration;
            serialized["videoCodec"]       = VideoCodec.ToBrightcoveName();

            return(serialized);
        }
Exemplo n.º 34
0
        public CalcData(long frames, decimal fps, ContainerType container, VideoCodec codec, bool bframes, AudioBitrateCalculationStream[] audios)
        {
            if (fps <= 0) throw new ArgumentException("Frames per second must be greater than zero.", "fps");
            if (frames <= 0) throw new ArgumentException("Frames must be greater than zero.", "frames");

            Frames = frames;
            FramesPerSecond = fps;
            ContainerType = container;
            VideoCodec = codec;
            HasBFrames = bframes;
            AudioStreams = audios;
            VideoOverheadRatio = 1;
            AudioOverheadRatio = 1;
            ExtraOverheadRatio = 1;
            QualityCoeffient = 0.75F;
        }
Exemplo n.º 35
0
 /// <summary>
 /// Parse all the values that are shared between shows and movies
 /// </summary>
 /// <param name="input">Input string</param>
 /// <param name="dir">Switch whenever it is a directory name.</param>
 private void ParseShared(String input, Boolean dir = false)
 {
     String inputCl = helperDictionary.CleanFileName(input);
     Int32 TmpStart;
     String TmpString;
     #region videoQuality
     if (videoQuality == VideoQuality.Unknown)
     {
         TmpString = Check(inputCl, helperDictionary.VideoQualityStrings, out TmpStart);
         videoQuality = helperDictionary.StrToVideoQuality(TmpString);
         if (TmpString.Length > 0)
             Index.Add(new StringLocation(TmpString, TmpStart, TmpString.Length, true, dir));
     }
     #endregion
     #region videoSource
     if (videoSource == VideoSource.Unknown)
     {
         TmpString = Check(inputCl, helperDictionary.VideoSourceStrings, out TmpStart);
         videoSource = helperDictionary.StrToVideoSource(TmpString);
         if (TmpString.Length > 0)
             Index.Add(new StringLocation(TmpString, TmpStart, TmpString.Length, true, dir));
     }
     #endregion
     #region container
     if (container == Container.Unknown & !dir)
     {
         //TmpString = Check(fileExt, helperDictionary.ContainerStrings, out TmpStart);
         container = helperDictionary.StrToContainer(fileExt);
         //if (TmpString.Length > 0)
         //Index.Add(new StringLocation(TmpString, TmpStart, TmpString.Length, true, dir));
     }
     #endregion
     #region videoCodec
     if (videoCodec == VideoCodec.Unknown)
     {
         TmpString = Check(inputCl, helperDictionary.VideoCodecStrings, out TmpStart);
         videoCodec = helperDictionary.StrToVideoCodec(TmpString);
         if (TmpString.Length > 0)
             Index.Add(new StringLocation(TmpString, TmpStart, TmpString.Length, true, dir));
     }
     #endregion
     #region audioCodec
     if (audioCodec == AudioCodec.Unknown)
     {
         TmpString = Check(inputCl, helperDictionary.AudioCodecStrings, out TmpStart);
         audioCodec = helperDictionary.StrToAudioCodec(TmpString);
         if (TmpString.Length > 0)
             Index.Add(new StringLocation(TmpString, TmpStart, TmpString.Length, true, dir));
     }
     #endregion
     #region sample
     //Check if our file is a sample
     if (!sample)
     {
         TmpStart = inputCl.IndexOf("sample");
         if (TmpStart > -1 & (fileSize < 1024 * 1024 * 1024))
         {
             sample = true;
             Index.Add(new StringLocation("sample", TmpStart, 6, true, dir));
         }
     }
     #endregion
 }
Exemplo n.º 36
0
 internal bool InitVideoH264(byte[] pSPS, byte[] pPPS)
 {
     ClearVideo();
     if (!Avc.Init(pSPS, pPPS))
     {
         ClearVideo();
         return false;
     }
     VideoCodecId = VideoCodec.H264;
     return true;
 }
Exemplo n.º 37
0
        /// <summary>
        /// Initializing the MainForm combo boxes content.
        /// </summary>
        private void InitializeDropDownMenus()
        {
            this.selectCodecComboBox.DataSource = Enum.GetValues(typeof(VideoCodec));
            this.selectCodecComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            this.selectCodecComboBox.SelectedIndex = 3;
            this.videoCodec = (VideoCodec)this.selectCodecComboBox.SelectedValue;

            this.selectBitRateComboBox.DataSource = Enum.GetValues(typeof(BitRate));
            this.selectBitRateComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            this.selectBitRateComboBox.SelectedIndex = 3;
            this.bitRate = (int)this.selectBitRateComboBox.SelectedValue;
        }        
Exemplo n.º 38
0
 public string extension(VideoCodec idCodec)
 {
     switch (idCodec)
     {
         case VideoCodec.MPEG4: return ".mp4";
         case VideoCodec.FLV1: return ".flv";
         case VideoCodec.WMV2: return ".wmv";
         case VideoCodec.Raw: return ".avi";
         default: throw new ArgumentException("Este codec no está soportado.");
     }
 }
        private void OpenVideoWriters(string filePathBase, VideoCodec codec, int bitrate)
        {
            lock (lockObj)
            {
                if (Context.IsKinectActive)
                {
                    // color
                    videoWriterKinectColor = new VideoFileWriter();                   
                    int colorWidth = Context.ColorResizedWidth;
                    int colorHeight = Context.ColorResizedHeight;
                    if (Context.ProcessColorMapping) colorHeight *= 2;                                       
                    videoWriterKinectColor.Open(filePathBase + "_Color.avi", colorWidth, colorHeight, 30, codec, bitrate);                        

                    //depth
                    videoWriterKinectDepth = new VideoFileWriter();
                    int depthWidth = Context.DepthWidth;
                    int depthHeight = Context.DepthHeight;
                    if (Context.ProcessDepthMapping) depthHeight *= 2;
                    videoWriterKinectDepth.Open(filePathBase + "_Depth.avi", depthWidth, depthHeight, 30, VideoCodec.Raw, bitrate);                    

                    // body
                    bufferBody = new List<float[]>();
                }
                if (Context.IsPS3EyeActive)
                {
                    int fps = Context.IsKinectActive ? 30 : Context.GUI.PS3EyePanel.FrameRate;                  // fps depends on devices !!
                    videoWriterPS3Eye = new VideoFileWriter();
                    videoWriterPS3Eye.Open(filePathBase + "_PS3Eye.avi", 640, 480 * 2, fps, codec, bitrate);
                }

                currFilePathBase = filePathBase;
            }
        }        
Exemplo n.º 40
0
        private void visualizandoCam_Load(object sender, EventArgs e)
        {
            this.Resolucion = hConfig.interpretarResolucion(Settings.Default.Resolucion);
            this.Codec = hConfig.interpretaCodec(Settings.Default.Codec);

            /* Empezando con la reproducción y poniendo el titulo de la cámara. */
            reproduce(rutaCamara);
            this.Text = this.tituloVentana;
        }
Exemplo n.º 41
0
 public RecordSettings( string outputPath, Rectangle captureRectangle, int fps = 30, int interval = 500, VideoCodec codec = VideoCodec.MPEG4, int bitrate = 20, int? splitInterval = null, Action<TimeSpan> onFrameWritten = null ) {
     OutputPath = outputPath;
     CaptureRectangle = captureRectangle;
     OnFrameWritten = onFrameWritten;
     Interval = interval;
     Fps = fps;
     Codec = codec;
     Bitrate = bitrate;
     SplitInterval = splitInterval;
     Private = false;
 }
Exemplo n.º 42
0
 private void ClearVideo()
 {
     if (VideoCodecId == VideoCodec.H264)
         Avc.Clear();
     VideoCodecId = VideoCodec.PassThrough;
 }