public ActionResult Index()
        {
            string url     = "https://www.youtube.com/watch?v=bDuzU4XLEEs";
            var    youTube = YouTube.Default;       // starting point for YouTube actions
            var    video   = youTube.GetVideo(url); // gets a Video object with info about the video

            //System.IO.File.WriteAllBytes(@"C:\Downloads\" + video.FullName, video.GetBytes());
            var videoName = @"C:\Downloads\" + video.FullName;
            var ffmpeg    = new NReco.VideoConverter.FFMpegConverter();

            using (System.IO.Stream stream = new System.IO.MemoryStream(video.GetBytes(), 0, video.GetBytes().Length))
            {
                stream.Write(video.GetBytes(), 0, video.GetBytes().Length);

                ffmpeg.ConvertLiveMedia(stream, Format.mp4, @"C:\Downloads\result2.gif", Format.gif, new ConvertSettings()
                {
                    VideoFrameRate = 1, MaxDuration = 10
                });
            }
            ffmpeg.ConvertMedia(videoName, null, @"C:\Downloads\result.gif", null, new ConvertSettings()
            {
                VideoFrameRate = 1, MaxDuration = 10
            });

            var k = ffmpeg.ConvertLiveMedia(video.Stream(), Format.mp4, @"C:\Downloads\result2.gif", null, new ConvertSettings()
            {
                VideoFrameRate = 1, MaxDuration = 10
            });

            k.Start();



            return(View());
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Realtime Audio Transcriber");
            audioProcesser = new AudioProcessor();
            var ffMpeg = new NReco.VideoConverter.FFMpegConverter();

            ffMpeg.LogLevel     = "verbose";
            ffMpeg.LogReceived += logs;
            outputStream        = new MemoryStream();
            Console.WriteLine("Created FFMPeg");
            string streamUrl = "testing_file.mp3";

            audioProcesser.AudioStart();
            var vidtask = ffMpeg.ConvertLiveMedia(streamUrl, null, outputStream, "wav", new ConvertSettings
            {
                CustomOutputArgs = "-vn -r 25 -c:a pcm_s16le -b:a 16k -ac 1 -ar 16000"
            });

            vidtask.OutputDataReceived += DataReceived;
            Console.WriteLine("Starting");
            vidtask.Start();
            Console.WriteLine("Started");
            vidtask.Wait();
            byte[] buffer = new byte[2048]; // using 2kB byte arrays
            int    bytesRead;

            Console.Read();
            //connection.Stop();
            Console.WriteLine("Complete");
        }
        public ActionResult Index()
        {
            string url     = "https://www.youtube.com/watch?v=7TxEZvkjwhk";
            var    youTube = YouTube.Default;       // starting point for YouTube actions
            var    video   = youTube.GetVideo(url); // gets a Video object with info about the video

            System.IO.File.WriteAllBytes(@"C:\Downloads\" + video.FullName, video.GetBytes());
            var videoName = @"C:\Downloads\" + video.FullName;
            var ffmpeg    = new NReco.VideoConverter.FFMpegConverter();

            System.IO.Stream stream = new System.IO.MemoryStream(video.GetBytes());

            // ffmpeg.ConvertMedia(videoName, null, @"C:\Downloads\result.gif", null, new ConvertSettings() { VideoFrameRate = 1, MaxDuration = 10 });
            ffmpeg.ConvertLiveMedia(stream, "mp4", @"C:\Downloads\result.gif", null, new ConvertSettings()
            {
                VideoFrameRate = 1, MaxDuration = 10
            });
            return(View());
        }