/// <summary>
        /// Concat a second video at the end of the main video.
        /// </summary>
        /// <param name="secondVideo">The second video to add at the end of the main one.</param>
        public void concatVideos(Video secondVideo)
        {
            /* Conversion of both videos */
            //this.video.convertVideo();
            //secondVideo.convertVideo();

            /* Settings needed to concatenate the videos */
            String[] inputVideoPaths = new String[2];
            String   outputVideoPath = this.video.filePath;
            String   outputName      = this.video.fileName;
            String   newPath         = "C:\\Users\\Théo\\Desktop\\videos\\final.mp4";
            String   commandConcat   = "- i \"concat:" + this.video.filePath + "|" + secondVideo.filePath + "\" - codec copy " + outputVideoPath;
            long     outputSize      = video.fileSize + secondVideo.fileSize;

            inputVideoPaths[0] = video.filePath;
            inputVideoPaths[1] = secondVideo.filePath;

            var concatSetting = new NReco.VideoConverter.ConcatSettings();

            //concatSetting.ConcatVideoStream = true;
            //concatSetting.ConcatAudioStream = false;
            //concatSetting.VideoCodec = "h264";
            //concatSetting.VideoFrameRate = 30;
            //concatSetting.SetVideoFrameSize(1280, 720);


            processPercentage = "0 %";
            ffMpegConverter.ConvertProgress += updateProgress;
            ffMpegConverter.ConcatMedia(inputVideoPaths, newPath, Format.mp4, concatSetting);


            video = new Model.Video(newPath, "final", outputSize);
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string input = @"C:\Users\a\Videos\Debut\Untitled 7.avi";

            string output = "C:\\test3.avi";

            var setting = new NReco.VideoConverter.ConvertSettings();

            setting.SetVideoFrameSize(1280, 720);
            setting.CustomInputArgs = "-ss 00:00:00 -t 00:00:10";
            // setting.CustomOutputArgs = "-vf vflip";
            setting.CustomOutputArgs = "-vf \"movie=logo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]\"";


            //            Top left corner
            //ffmpeg -i inputvideo.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=10:10 [out]" outputvideo.flv

            //Top right corner
            //ffmpeg -i inputvideo.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" outputvideo.flv

            //Bottom left corner
            //ffmpeg -i inputvideo.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=10:main_h-overlay_h-10 [out]" outputvideo.flv

            //Bottom right corner
            //ffmpeg -i inputvideo.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" outputvideo.flv



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

            ffMpeg.ConvertProgress += FfMpeg_ConvertProgress;

            ffMpeg.GetVideoThumbnail(input, "temp.jpg", 10.0f);
            System.IO.FileStream hStream = new System.IO.FileStream("temp.jpg", System.IO.FileMode.Open);
            this.pictureBox1.Image = Image.FromStream(hStream);
            // FileStream を閉じる (正しくは オブジェクトの破棄を保証する を参照)
            hStream.Close();
            return;

            //ffMpeg.ConvertMedia(input, null, output, null, setting);

            ffMpeg.ConvertMedia(input, null, output, NReco.VideoConverter.Format.mp4, setting);
            //


            NReco.VideoConverter.ConcatSettings set = new NReco.VideoConverter.ConcatSettings();
            set.SetVideoFrameSize(640, 480);
            //ffMpeg.ConcatMedia(_fileNames, videoRootPath + tobename + ".mp4", NReco.VideoConverter.Format.mp4, set);

            this.Text = "FINISH";
        }
示例#3
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]);
                }
            }
        }