Example #1
0
        private void LoadVideoBtn_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileBrowser = new OpenFileDialog
            {
                Filter = "MP4 file (*.mp4)|*.mp4"
            };

            if (fileBrowser.ShowDialog() != true)
            {
                return;
            }

            btnLoadVideo.IsEnabled = false;

            Options options = new Options();
            var     ops     = Parser.Default.ParseArguments <Options>(new string[] { "--input_file", fileBrowser.FileName }).WithParsed(x => options = x);
            var     jc      = new JumpCutter(options);

            //jumpcutter = new Thread(delegate ()
            //{

            jc.WPFStage1();
            //});
            //jumpcutter.Start();
        }
Example #2
0
        // Open mp4 file for processing
        private void OpenFile(string fileName)
        {
            Stop();
            var cmdLineOpts = new string[] { "--input_file", fileName };
            var ops         = Parser.Default.ParseArguments <Options>(cmdLineOpts);

            ops.WithParsed(x => options = x);


            jc = new JumpCutter(ref options);

            var videoProcessor = new Thread(delegate() {
                jc.WPFStageVideo();
                jc.WPFStageAudio();
                jc.audioProcessor.prepareStream();
                jc.audioProcessor.stream.AudioFrameRendered += new JumpCutterStreamProcessor.AudioFrameHandler(renderFrame);
            });



            var processAudio = new Thread(delegate()
            {
                videoProcessor.Start();
                //Wait for the video processor to init and handle the callback to render a frame
                videoProcessor.Join();
                jc.audioProcessor.Stream();
            });

            processAudio.Start();



            //  if (//processor.OpenWavFile(jc.options.temp_audio ) == true)
            // {
            //     button_play.IsEnabled = true;
            //     button_stop.IsEnabled = true;
            //
            //     // Parse adjustment settings
            //     SetTempo(0);
            // }
            // else
            // {
            //     button_play.IsEnabled = false;
            //     button_stop.IsEnabled = false;
            //     MessageBox.Show("Coudln't open audio file " + fileName);
            // }
        }
Example #3
0
        static int Main(string[] args)
        {
            var withError = false;

            Console.WriteLine();

            Options options = new Options();
            var     ops     = Parser.Default.ParseArguments <Options>(args).WithParsed(x => options = x);

            if (ops.Tag == ParserResultType.Parsed)
            {
                var jc            = new JumpCutter(ref options);
                var lockFileError = false;
                try
                {
                    try
                    {
                        jc.Process();
                    }
                    catch (FileLoadException e)
                    {
                        lockFileError = true;
                        Console.Error.WriteLine(e);
                    }
                    catch (Exception e)
                    {
                        throw new JCException("\tUncaught Exception", e);
                    }
                }
                catch (JCException e)
                {
                    Console.Error.WriteLine("\tError: " + e.Message);
                    var ie    = e.InnerException;
                    var count = 0;
                    while (ie != null)
                    {
                        count++;
                        var tabs = String.Concat(Enumerable.Repeat("\t", count));
                        Console.Error.WriteLine(tabs + "Inner Error: " + ie.Message);
                        ie = ie.InnerException;
                    }
                    withError = true;
                }
                finally
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(options.temp_dir))
                        {
                            var tempdir = new DirectoryInfo(options.temp_dir);
                            if (tempdir.Exists)
                            {
                                tempdir.Delete(true);
                            }
                        }
                        if (!lockFileError)
                        {
                            jc.lockfile?.Delete();
                        }
                    }
                    catch (Exception)
                    {
                        Console.Error.WriteLine("Failed to cleanup temp dir " + options.temp_dir);
                    }
                }
            }
            //Console.ReadKey();
            return(withError ? -1 : 0);
        }