예제 #1
0
 static void LoadVideo()
 {
     IOUtils.ClearDir(Paths.framesOutPath);
     fps = FFmpegCommands.GetFramerate(currentInPath);
     Print("Detected frame rate of video as " + fps);
     IOUtils.ClearDir(Paths.imgInPath);
 }
예제 #2
0
        //------------------------------

        public void OnAppend()
        {
            config.inputPaths.Clear();

            //Collect input paths. NOTE: Videos should be in same orientation.
            foreach (InputField inputField in inputFields)
            {
                config.inputPaths.Add(
                #if UNITY_IOS && !UNITY_EDITOR
                    inputField.gameObject.GetComponentInChildren <IOS.IOSInputView>().iosPath.text);
                #else
                    inputField.text);
                #endif
            }

            if (fastMode)
            {
                FFmpegCommands.AppendFast(config);
            }
            else
            {
                FFmpegCommands.AppendFull(config);
            }

            gameObject.SetActive(false);
        }
예제 #3
0
        void CreateVideo()
        {
            StringBuilder command = new StringBuilder();

            Debug.Log("firstImgFilePath: " + firstImgFilePath);
            Debug.Log("soundPath: " + soundPath);
            Debug.Log("outputVideoPath: " + outputVideoPath);

            //Input Image sequence params
            command.
            Append("-y -framerate ").
            Append(actualFPS.ToString()).
            Append(" -f image2 -i ").
            Append(AddQuotation(firstImgFilePath));

            //Input Audio params
            if (recAudioSource != RecAudioSource.None)
            {
                command.
                Append(" -i ").
                Append(AddQuotation(soundPath)).
                Append(" -ss 0 -t ").
                Append(totalTime);
            }

            //Output Video params
            command.
            Append(" -vcodec libx264 -crf 25 -pix_fmt yuv420p ").
            Append(AddQuotation(outputVideoPath));

            Debug.Log(command.ToString());

            FFmpegCommands.DirectInput(command.ToString());
        }
예제 #4
0
        //------------------------------

        public void OnAddSound()
        {
            if (fastMode)
            {
                FFmpegCommands.AddSoundFast(config);
            }
            else
            {
                FFmpegCommands.AddSoundFull(config);
            }

            gameObject.SetActive(false);
        }
예제 #5
0
        void CreateVideo()
        {
            StringBuilder command = new StringBuilder();

            command.
            Append("-y -framerate ").
            Append(actualFPS.ToString()).
            Append(" -f image2 -i ").
            Append(firstImgFilePathEnclosed).
            Append(" -vcodec libx264 -crf 25 -pix_fmt yuv420p ").
            Append(outputVideoPath);

            Debug.Log(command.ToString());

            FFmpegCommands.DirectInput(command.ToString());
        }
예제 #6
0
        static async Task CreateVideo()
        {
            if (IOUtils.GetAmountOfFiles(Paths.framesOutPath, false) < 1)
            {
                return;
            }

            if (outputFormatBox.Text == Upscale.VidExportMode.MP4.ToStringTitleCase())
            {
                outputFormat = Upscale.VidExportMode.MP4;
            }
            if (outputFormatBox.Text == Upscale.VidExportMode.GIF.ToStringTitleCase())
            {
                outputFormat = Upscale.VidExportMode.GIF;
            }
            if (outputFormatBox.Text == Upscale.VidExportMode.SameAsSource.ToStringTitleCase())
            {
                outputFormat = (Upscale.VidExportMode)Enum.Parse(typeof(Upscale.VidExportMode), Path.GetExtension(currentInPath).Replace(".", "").ToUpper());
            }

            if (outputFormat == Upscale.VidExportMode.MP4)
            {
                DialogForm f = new DialogForm("Creating video from frames...", 300);
                await Task.Delay(10);

                await FFmpegCommands.FramesToMp4(Paths.framesOutPath, Config.GetBool("h265"), Config.GetInt("crf"), fps, "", false);

                if (Config.GetBool("vidEnableAudio"))
                {
                    await FFmpegCommands.MergeAudio(Paths.framesOutPath + ".mp4", currentInPath);
                }
                f.Close();
            }

            if (outputFormat == Upscale.VidExportMode.GIF)
            {
                DialogForm f = new DialogForm("Creating GIF from frames...\nThis can take a while for high-resolution GIFs.", 600);
                await Task.Delay(10);

                string outpath = Path.Combine(Paths.GetDataPath(), "frames-out.mp4").Wrap();
                await FFmpeg.RunGifski($" -r {fps.RoundToInt()} -W 4096 -Q {Config.GetInt("gifskiQ")} -q -o {outpath} \"{Paths.framesOutPath}/\"*.\"png\"");

                f.Close();
            }
        }
예제 #7
0
        public void PickTrimPlay()
        {
            NativeGallery.Permission permission = NativeGallery.GetVideoFromGallery((path) =>
            {
                if (path != null)
                {
                    // Play the selected video
                    config.inputPath = path;
                    //watermarkData.inputPath = path;
                    config.outputPath = path.Substring(0, path.Length - 4) + "_Trimmed.mp4";
                    //watermarkData.outputPath = path.Substring(0, path.Length - 4) + "_Trimmed.mp4";
                    pathNewVideoToPlay = config.outputPath;

                    FFmpegCommands.Trim(config);
                    //FFmpegCommands.Watermark(watermarkData);
                }
            }, "Select a video");
        }
예제 #8
0
        public static async Task Run(bool preprocess)
        {
            logBox.Clear();
            Print("Starting upscale of " + Path.GetFileName(currentInPath));
            if (string.IsNullOrWhiteSpace(currentInPath) || !File.Exists(currentInPath))
            {
                Program.ShowMessage("No valid file loaded.", "Error");
                return;
            }
            if (!IOUtils.HasEnoughDiskSpace(IOUtils.GetAppDataDir(), 10.0f))
            {
                Program.ShowMessage($"Not enough disk space on {IOUtils.GetAppDataDir().Substring(0, 3)} to store temporary files!", "Error");
                return;
            }
            Program.mainForm.SetBusy(true);
            LoadVideo();
            Print("Extracting frames...");
            await FFmpegCommands.VideoToFrames(currentInPath, Paths.imgInPath, false, false, false);

            int amountFrames = IOUtils.GetAmountOfCompatibleFiles(Paths.imgInPath, false);

            Print($"Done - Extracted  {amountFrames} frames.");
            await PreprocessIfNeeded(preprocess);

            BatchUpscaleUI.LoadDir(Paths.imgInPath, true);
            Print("Upscaling frames...");
            await BatchUpscaleUI.Run(false, true, Paths.framesOutPath);

            RenameOutFiles();
            Print($"Done upscaling all frames.");
            BatchUpscaleUI.Reset();
            Print("Creating video from frames...");
            await CreateVideo();

            Print("Done creating video.");
            CopyBack(Path.Combine(IOUtils.GetAppDataDir(), "frames-out.mp4"));
            Print("Adding audio from source to output video...");
            IOUtils.ClearDir(Paths.imgInPath);
            IOUtils.ClearDir(Paths.framesOutPath);
            Program.mainForm.SetBusy(false);
            Print("Finished.");
        }
예제 #9
0
    public static void Convert(string audio, string video, string output, ref bool done)
    {
        var inputPath  = Application.persistentDataPath + "/" + video;
        var soundPath  = Application.persistentDataPath + "/" + audio;
        var outputPath = Application.persistentDataPath + "/" + output;

        FFmpegParser.Handler = new FFmpegHandler(output);

        // -t seconds?
        FFmpegCommands.DirectInput(
            //"-re -f lavfi -i \"movie=\\'" + inputPath + "\\':loop=0, setpts=N/(FRAME_RATE*TB)\" -i '" + soundPath + "' -map 0:v:0 -map 1:a:0 -shortest " + outputPath
            "-y -i \"C:/Users/Bjorn/AppData/LocalLow/Totsj/mp4Converter/VideoBackground.mov\" \"C:/Users/Bjorn/AppData/LocalLow/Totsj/mp4Converter/out.mp4\" \"C:/Users/Bjorn/AppData/LocalLow/Totsj/mp4Converter/Crusade Runner.mp4\""
            );

        /*DecodeEncodeData config = new DecodeEncodeData();
         * config.fps = 1;
         * config.inputPath = inputPath;
         * config.soundPath = soundPath;
         * config.outputPath = outputPath;
         *
         * FFmpegCommands.Encode(config);*/
    }
예제 #10
0
    void Update()
    {
        timer += Time.deltaTime;

        if (capturing)
        {
            StartCoroutine(TakePhotoEnumerator());
        }
        if (encoding)
        {
            encoding = false;

            // Save audio clip to wav file
            Microphone.End("audio");
            audio = savWav.TrimSilence(audio, 0);
            savWav.Save(string.Format("{0}/audio", realFolder), audio);
            OnImagesPathInput();
            OnSoundPathInput();
            OnOutputPathInput();
            OnFPSInput();
            FFmpegCommands.Encode(config);
        }
    }
예제 #11
0
        //------------------------------

        public void OnTrim()
        {
            FFmpegCommands.Trim(config);

            gameObject.SetActive(false);
        }
예제 #12
0
        //------------------------------

        public void OnDecode()
        {
            FFmpegCommands.Decode(config);
            gameObject.SetActive(false);
        }
        //------------------------------

        public void OnCompress()
        {
            FFmpegCommands.Compress(config);
            gameObject.SetActive(false);
        }
예제 #14
0
        //------------------------------

        public void OnWatermark()
        {
            FFmpegCommands.Watermark(config);
            gameObject.SetActive(false);
        }
예제 #15
0
 public void MakeGif(Action method)
 {
     FFmpegCommands.MakeGif(Application.streamingAssetsPath + "/png/%d.png", Application.streamingAssetsPath + "/gif/yb.gif");
     succeed += method;
 }
예제 #16
0
        //------------------------------

        public void OnDirectInput(string commands)
        {
            FFmpegCommands.DirectInput(commands);
        }
예제 #17
0
        //------------------------------

        public void OnVersion()
        {
            FFmpegCommands.GetVersion();
        }