Example #1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            var ffMpeg = new NReco.VideoConverter.FFMpegConverter();

            NReco.VideoConverter.ConcatSettings set = new NReco.VideoConverter.ConcatSettings();
            set.SetVideoFrameSize(640, 480);
            set.ConcatAudioStream = false;
            set.ConcatVideoStream = true;
            //set.CustomOutputArgs = "-filter_complex '[0:v] setsar=sar=1 [in1]; [1:v] setsar=sar=1 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]'";
            //set.CustomOutputArgs = "-filter_complex \"[0:0] setsar=1/1[sarfix];[sarfix] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a] \" -map \"[v]\" -map \"[a]\"";
            string[] inputfiles = { "opening.mp4", tempout };
            ffMpeg.ConcatMedia(inputfiles, output, NReco.VideoConverter.Format.mp4, set);
            MessageBox.Show("FINISHED");
        }
        public void ExportVideo(ProgressDialogController progress)
        {
            string inputFile = @Manager.Match.VideoFile;
            string videoName = Manager.Match.VideoFile.Split('\\').Last();

            videoName = videoName.Split('.').First();
            Directory.CreateDirectory(@Location);
            string collectionName = @Location + @"\" + Manager.ActivePlaylist.Name + "_collection.mp4";
            int    rallyCount     = Manager.ActivePlaylist.Rallies.Count();
            int    sum            = 0;

            for (int s = 1; s <= rallyCount; s++)
            {
                sum = sum + s;
            }
            if (rallyCollection)
            {
                progressBar = sum * 2;
            }
            else
            {
                progressBar = sum;
            }

            currentProgress = 0;

            string[] RallyCollection = new string[rallyCount];
            string[] ConcatRally     = new string[2];
            progress.Minimum = 0;
            progress.Maximum = progressBar;
            progress.SetProgress(0);

            for (int i = 0; i < rallyCount; i++)
            {
                progress.SetMessage("Export Playlist '" + Manager.ActivePlaylist.Name + "': \n\nRally " + (i + 1) + " is being created...");
                Rally  curRally    = Manager.ActivePlaylist.Rallies[i];
                string RallyNumber = curRally.Number.ToString();
                string RallyScore  = curRally.CurrentRallyScore.ToString();
                RallyScore = RallyScore.Replace(":", "-");
                string SetScore = curRally.CurrentSetScore.ToString();
                SetScore = SetScore.Replace(":", "-");
                string fileName = @Location + @"\#" + RallyNumber + "_" + RallyScore + " (" + SetScore + ").mp4";
                RallyCollection[i] = fileName;

                var ffMpeg = new NReco.VideoConverter.FFMpegConverter();

                NReco.VideoConverter.ConvertSettings settings = new NReco.VideoConverter.ConvertSettings()
                {
                    Seek        = Convert.ToSingle(curRally.Start / 1000),
                    MaxDuration = Convert.ToSingle((curRally.End - curRally.Start) / 1000),
                    //VideoFrameSize = NReco.VideoConverter.FrameSize.hd720,
                    AudioCodec = "copy", VideoCodec = "copy"
                };
                ffMpeg.ConvertMedia(@Manager.Match.VideoFile, null, fileName, null, settings);


                currentProgress = currentProgress + (i + 1);
                progress.SetProgress(currentProgress);
            }

            if (rallyCollection)
            {
                progress.SetMessage("\n Collection is currently being created! \n\nIt may take a while...");
                var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
                ffMpeg.ConvertProgress += UpdateProgress;

                NReco.VideoConverter.ConcatSettings settings = new NReco.VideoConverter.ConcatSettings();
                ffMpeg.ConcatMedia(RallyCollection, @Location + @"\" + Manager.ActivePlaylist.Name + "_collection(" + rallyCount + ").mp4", NReco.VideoConverter.Format.mp4, settings);
                progress.SetProgress(progressBar);
            }

            if (!singleRallies)
            {
                for (int i = 0; i < rallyCount; i++)
                {
                    File.Delete(RallyCollection[i]);
                }
            }
        }