Example #1
0
        public static void Startffmpeg()
        {
            var rtsp = ConfigurationManager.AppSettings["rtsp"];

            var pathFF = MediaHelper.FFmpegImgfolder();

            MediaHelper.EnsureDirCreated(pathFF);

            var fps = ConfigurationManager.AppSettings["fps"];

            var cmd    = $"-i {rtsp} -vf fps={fps} {pathFF}\\ffout%d.png";
            var ffPath = ConfigurationManager.AppSettings["ffPath"];

            RunProcessBlock(cmd, ffPath);
        }
Example #2
0
        public void StartAsync()
        {
            Task.Run(() =>
            {
                var vcaPath = MediaHelper.VcaImgfolder();
                var ffPath  = MediaHelper.FFmpegImgfolder();

                MediaHelper.EnsureDirCreated(vcaPath, ffPath);
                while (true)
                {
                    try
                    {
                        var allImgs  = Directory.GetFiles(ffPath).OrderBy(x => x).ToList();
                        string first = string.Empty;

                        ////try take one image from ffmpeg folder
                        if (allImgs.Count > 0)
                        {
                            first = allImgs[0];

                            var fileName   = MediaHelper.FileName(first);
                            var vcaImgPath = $"{vcaPath}\\{fileName}";
                            if (File.Exists(vcaImgPath))
                            {
                                vcaImgPath = MediaHelper.UniquePath(vcaImgPath);
                            }
                            File.Move(first, vcaImgPath);
                        }
                        Thread.Sleep(1000);
                    }
                    catch (Exception ex)
                    {
                        // locked by ffmpeg, skip, later will try again
                    }
                }
            });
        }