GetVolumeLevel() public method

public GetVolumeLevel ( int microphoneId ) : VolumeLevel
microphoneId int
return VolumeLevel
Ejemplo n.º 1
0
        internal void MergeMedia()
        {
            if (_ffmpegProcess != null)
            {
                return;
            }

            if (!Helper.HasFeature(Enums.Features.Recording))
            {
                return;
            }
            _pbMerge = new List <FilesFile>();

            _currentObject = ((Li)ddlObject.SelectedItem);
            if (_currentObject.Ot == 1)
            {
                var vl = MainClass.GetVolumeLevel(_currentObject.ID);
                _pbMerge = vl.FileList.Where(
                    p => p.CreatedDateTicks >= dateTimePicker1.Value.Ticks &&
                    p.CreatedDateTicks <= dateTimePicker2.Value.Ticks).OrderBy(p => p.CreatedDateTicks).ToList();
            }
            else
            {
                var cw = MainClass.GetCameraWindow(_currentObject.ID);
                _pbMerge = cw.FileList.Where(
                    p => p.CreatedDateTicks >= dateTimePicker1.Value.Ticks &&
                    p.CreatedDateTicks <= dateTimePicker2.Value.Ticks).OrderBy(p => p.CreatedDateTicks).ToList();
            }

            if (_pbMerge.Count > 0)
            {
                var    first = _pbMerge.First();
                string ext   = first.Filename.Substring(first.Filename.LastIndexOf(".", StringComparison.Ordinal) + 1);
                var    date  = DateTime.Now;

                _dir     = Helper.GetFullPath(_currentObject.Ot, _currentObject.ID);
                _outfile = _currentObject.ID + "_" +
                           $"Merge_{date.Year}-{Helper.ZeroPad(date.Month)}-{Helper.ZeroPad(date.Day)}_{Helper.ZeroPad(date.Hour)}-{Helper.ZeroPad(date.Minute)}-{Helper.ZeroPad(date.Second)}" + "." + ext;

                string filelist = _pbMerge.Aggregate("",
                                                     (current, file) => current + ("file '" + _dir + file.Filename + "'" + Environment.NewLine));

                File.WriteAllText(Program.AppDataPath + "concat.txt", filelist);
                if (filelist != "")
                {
                    var startInfo = new ProcessStartInfo
                    {
                        FileName  = "\"" + Program.AppPath + "ffmpeg.exe\"",
                        Arguments =
                            "-f concat -i \"" + Program.AppDataPath + "concat.txt" +
                            "\" -codec copy \"" + _dir + _outfile + "\"",
                        RedirectStandardOutput = false,
                        RedirectStandardError  = false,
                        UseShellExecute        = false,
                        CreateNoWindow         = false
                    };
                    Logger.LogMessageToFile("Merge: " + startInfo.FileName + " " + startInfo.Arguments);
                    _ffmpegProcess = new Process {
                        StartInfo = startInfo, EnableRaisingEvents = true
                    };
                    _ffmpegProcess.Exited            += FfmpegMergeProcessExited;
                    _ffmpegProcess.ErrorDataReceived += FfmpegMergeProcessErrorDataReceived;
                    try
                    {
                        _ffmpegProcess.Start();
                    }
                    catch (Exception e)
                    {
                        _ffmpegProcess = null;
                        Logger.LogExceptionToFile(e);
                    }
                }
                button1.Enabled = false;
            }
        }