private unsafe void Button_Test_Click(object sender, RoutedEventArgs e)
        {
            Bitmap bitmap = CreateTestBitmap();

            AVFrame *inFrame = FFmpegInvoke.avcodec_alloc_frame();

            if (inFrame == null)
            {
                throw new Exception("Could not allocate video frame");
            }
            inFrame->width  = bitmap.Width;
            inFrame->height = bitmap.Height;
            inFrame->format = (int)AVPixelFormat.AV_PIX_FMT_BGR24;

            int ret1 = FFmpegInvoke.av_image_alloc(&inFrame->data_0, inFrame->linesize, bitmap.Width, bitmap.Height, AVPixelFormat.AV_PIX_FMT_BGR24, 32);

            if (ret1 < 0)
            {
                throw new Exception("Could not allocate raw picture buffer");
            }

            VideoHelper.UpdateFrame(inFrame, bitmap);
            VideoConverter converterToYuv = new VideoConverter(AVPixelFormat.AV_PIX_FMT_YUV420P);
            var            data           = converterToYuv.ConvertFrame(inFrame);

            var bitmap2 = VideoHelper.CreateBitmap(data, bitmap.Width, bitmap.Height);

            SetImageSource(bitmap2);
        }
예제 #2
0
        public void DisplayExample()
        {
            var       converter = new VideoConverter();
            VideoFile file      = converter.Convert("funny-cats-video.ogg", "mp4");

            file.Save();
        }
예제 #3
0
        public ActionResult Upload(HttpPostedFileBase uploadFile)
        {
            string fileName = System.IO.Path.GetFileName(uploadFile.FileName);
            string filePhysicalPath = Server.MapPath("~/upload/" + fileName);
            string pic = "", error = "";

            try
            {
                uploadFile.SaveAs(filePhysicalPath);
                VideoConverter.Clear();
                bool success = VideoConverter.Tans2Mp4(filePhysicalPath);
                if (success)
                {
                    string destFile = VideoConverter.GetImage(filePhysicalPath);
                    pic = "/upload/" + Path.GetFileName(destFile);
                }
                else
                {
                    error = "转换失败!";
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Json(new
            {
                pic = pic,
                error = error
            }));
        }
예제 #4
0
        public void MainProcess()
        {
            var convertor = new VideoConverter();
            var mp4       = convertor.Convert("youtubevideo.ogg", "mp4");

            mp4.save();
        }
예제 #5
0
        public bool TryDecode(ref VideoPacket packet, out VideoFrame frame)
        {
            if (_videoDecoder == null)
            {
                _videoDecoder = new VideoDecoder();
            }

            frame = new VideoFrame();
            AVFrame avFrame;

            if (_videoDecoder.TryDecode(ref packet.Data, out avFrame))
            {
                if (_videoConverter == null)
                {
                    _videoConverter = new VideoConverter(_pixelFormat.ToAVPixelFormat());
                }

                frame.Timestamp   = packet.Timestamp;
                frame.FrameNumber = packet.FrameNumber;
                frame.Width       = packet.Width;
                frame.Height      = packet.Height;
                frame.PixelFormat = _pixelFormat;
                frame.Data        = _videoConverter.ConvertFrame(avFrame);

                return(true);
            }
            return(false);
        }
예제 #6
0
        private void Preview(string cmd)
        {
            string path = FindFile(cmd);

            if (isVideo(path))
            {
                Program.Logger.info("Found video!");
                VideoConverter videoConverter = new VideoConverter(path);
                videoConverter.Start();
            }
            else
            {
                if (path != null)
                {
                    Program.Logger.info("File found!");
                    Program.Logger.info("Displaying configurable preview");

                    Display display = new Display(path, false);
                    display.PreviewFrame();
                }
                else
                {
                    Program.Logger.info("File not found!");
                }
            }
        }
예제 #7
0
        public void createFile(string destFullDirectory, string videoDirectory, string hash, string email, string rootHost)
        {
            VideoConverter converter = new VideoConverter(destFullDirectory, videoDirectory);
            Exception      ex        = null;

            Models.File file = null;
            try
            {
                string outFilePath = converter.Start();
                converter.Dispose();
                file                   = new Models.File();
                file.Md5Hash           = hash;
                file.FilePath          = "/TempVideoFiles/" + email + "/" + hash + "/video/" + Path.GetFileName(outFilePath); // Path.Combine(videoDirectory, Path.GetFileName(outFilePath));
                file.EmailWhoConverted = email;
                file.Datetime          = DateTime.Now;
                _db.Files.Add(file);
                _db.SaveChanges();
                //System.IO.File.WriteAllText(Path.Combine(destFullDirectory, "saved.txt"), "Saved!");
            }
            catch (Exception e)
            {
                //System.IO.File.WriteAllText(Path.Combine(destFullDirectory, "catch.txt"), "Catch!");
                ex = e;
            }
            finally
            {
                //System.IO.File.WriteAllText(Path.Combine(destFullDirectory, "finally.txt"), "Finally!");

                //string messageFor = "Ссылка на скачивание видеофайла: " + Request.Url.Authority + "/Home/GetVideoFile/?hash=" + hash + "&id=" + file.Id + " \r\nПосле разового скачивания файл удалится с сервера.\r\nС уважением, компания WebLMS.\r\nhttp://weblms.ru";
                //string messageFor = "Ссылка на скачивание видеофайла: /Home/GetVideoFile/?hash=" + hash + "&id=" + file.Id + " После разового скачивания файл удалится с сервера.С уважением, компания WebLMS";
                string messageFor = ex == null && file != null?
                                    String.Format("Ссылка на скачивание видеофайла: {0}/Home/GetVideoFile/?hash={1}&id={2} \r\nПосле разового скачивания файл удалится с сервера.\r\nС уважением, компания WebLMS.\r\nhttp://weblms.ru", rootHost, hash, file.Id) :
                                        String.Format("Произошла ошибка при конвертации файла, попробуйте повторить операцию позже. Детали ошибки: \r\n{0}.\r\nС уважением, компания WebLMS.\r\nhttp://weblms.ru", ex.Message);

                //System.IO.File.WriteAllText(Path.Combine(destFullDirectory, "finally1.txt"), "Finally1!");
                try
                {
                    //System.IO.File.WriteAllText(Path.Combine(destFullDirectory, "finallyTry.txt"), "finallyTry!");
                    //ISender fileSender1 = new FileSender();
                    //fileSender1.SendFileLink(Path.Combine(destFullDirectory, "input.txt1"), "Отправляется!");

                    //ISender emailSender = new FileSender();
                    //emailSender.SendFileLink(Path.Combine(destFullDirectory, "output.txt"), messageFor);

                    ISender emailSender = new EmailSender();
                    emailSender.SendFileLink(email, messageFor);

                    //System.IO.File.WriteAllText(Path.Combine(destFullDirectory, "email.txt"), messageFor);
                    //fileSender1.SendFileLink(Path.Combine(destFullDirectory, "input.txt2"), "Отправлено!");
                }
                catch (Exception e)
                {
                    //System.IO.File.WriteAllText(Path.Combine(destFullDirectory, "input3.txt"), e.Message);

                    //ISender fileSender = new FileSender();
                    //fileSender.SendFileLink(Path.Combine(destFullDirectory, "input3.txt"), e.Message);
                }
            }
        }
 private void bgWorkerUser_DoWork(object sender, DoWorkEventArgs e)
 {
     DateTime dateNow = DateTime.Now;
     parent = db.addVideo(textBoxVideoName.Text, textBoxVideoPath.Text, dateNow.ToString());
     VideoConverter vdc = new VideoConverter();
     path = vdc.Convert(path);
     fileSource = new FileVideoSource(path);
 }
예제 #9
0
        static void Main(string[] args)
        {
            var converter = new VideoConverter();

            var mp4 = converter.Convert("test.ogg", "mp4");

            mp4.Save();
        }
        public async void ExecuteEmptyQueue()
        {
            _provider.Setup(x => x.GetNext())
            .ReturnsAsync(() => null);

            var  videoConverter = new VideoConverter(_ffmpeg.Object, _settings.Object, _logger.Object, _provider.Object, null);
            bool result         = await videoConverter.Execute();

            Assert.False(result);
        }
예제 #11
0
 public UpdateMatchQueue(
     IServiceProvider serviceProvider,
     VideoConverter videoConverter,
     ILogger <UpdateMatchQueue> logger)
 {
     _serviceProvider  = serviceProvider;
     _videoConverter   = videoConverter;
     _logger           = logger;
     _updateMatchQueue = new ConcurrentQueue <Func <CancellationToken, Task> >();
     _signal           = new SemaphoreSlim(0);
 }
예제 #12
0
        public VideoResult VideoResultConverter(string link, string thumbnail)
        {
            var converters = new VideoConverter();
            var converter  = converters.SearchKnownSite(link);

            if (thumbnail == null || converter == null)
            {
                return(null);
            }
            return(new VideoResult(converter(link), thumbnail));
        }
        public async void Execute()
        {
            _provider.Setup(x => x.GetNext())
            .ReturnsAsync(new FileInfo(Path.GetTempFileName()));

            var  videoConverter = new VideoConverter(_ffmpeg.Object, _settings.Object, _logger.Object, _provider.Object, null);
            bool result         = await videoConverter.Execute();

            _ffmpeg.VerifyAll();
            Assert.True(result);
        }
예제 #14
0
        public NicoRankManager(NicoRankManagerMsgReceiver msg_receiver)
        {
            msg_receiver_      = msg_receiver;
            nico_download_     = new NicoNetworkManager(niconico_network_, msg_receiver_, cancel_object_);
            video_translater_  = new VideoConverter(msg_receiver_, cancel_object_);
            nico_list_manager_ = new NicoListManager(msg_receiver_);
            nico_mylist_       = new NicoMylist(niconico_network_, msg_receiver_, cancel_object_);
            tag_manager_       = new NicoTagManager(niconico_network_, msg_receiver_, cancel_object_);
            comment_manager_   = new NicoCommentManager(niconico_network_, msg_receiver_, cancel_object_);

            nico_download_.SetDelegateSetDonwloadInfo(msg_receiver_.SetDownloadInfo);
        }
예제 #15
0
        public ResponseFileInfo ConvertFile(UploadFileInfo request)
        {
            string           hash          = "";
            string           destDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WRecords");
            Stream           sourceStream  = null;
            ResponseFileInfo fileInfo      = null;

            try
            {
                fileInfo     = new ResponseFileInfo();
                sourceStream = new MemoryStream();
                sourceStream.Write(request.ByteArray, 0, request.ByteArray.Length);
                using (MD5 md5 = MD5.Create())
                {
                    hash = Hash.GetMD5Hash(md5, request.ByteArray);
                    string destFullDirectory = Path.Combine(destDirectory, request.Email, hash);
                    string videoDirectory    = Path.Combine(destFullDirectory, "video");

                    if (!Directory.Exists(destDirectory))
                    {
                        Directory.CreateDirectory(destDirectory);
                    }

                    if (!Directory.Exists(destFullDirectory))
                    {
                        Directory.CreateDirectory(destFullDirectory);
                        Directory.CreateDirectory(videoDirectory);
                        Zip.Unzip(sourceStream, destFullDirectory);
                    }
                    sourceStream.Dispose();

                    VideoConverter converter    = new VideoConverter(destFullDirectory, videoDirectory);
                    string         archiveError = converter.CheckArchiveCorrect();
                    if (archiveError != null)
                    {
                        throw new Exception(archiveError);
                    }

                    string outFilePath = converter.Start();
                    converter.Dispose();
                    fileInfo.Path = string.Format("WRecords/{0}/{1}/video/{2}", request.Email, hash, Path.GetFileName(outFilePath));
                    fileInfo.Hash = hash;
                }
            }
            catch (Exception e)
            {
                File.WriteAllText(Path.Combine(destDirectory, hash + "__catch.txt"), e.StackTrace);
            }
            return(fileInfo);
        }
예제 #16
0
        static async Task Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Console()
                         .CreateLogger();

            IServiceProvider sp             = BuildServiceProvider();
            BulkMediaUpdater updater        = sp.GetService <BulkMediaUpdater>();
            VideoConverter   videoConverter = sp.GetService <VideoConverter>();

            //await videoConverter.GenerateVideosAsync(default);

            await updater.CleanUpDeletedAsync(default);
예제 #17
0
        public async void ConvertVideo(string VideoPath)
        {
            var videoConverter = new VideoConverter();

            videoConverter.VideoConvertEvent += (s, e) =>
            {
                ProgressbarValue = e.ConvertProgress;
            };

            DownloadStatus = "Gör om video till mp3.";
            var savePath = await Task.Run(() => videoConverter.ConvertVideoToMp3(VideoPath));

            DownloadStatus = savePath != null ? "Nedladdning slutförd." : "Ett problem uppstod när videon skulle göras om till mp3.";
        }
예제 #18
0
        public async Task <string> CompressVideo(string path)
        {
            var inputFIle = new File(path);

            var videoConverter = new VideoConverter(Forms.Context);

            var outputFile = await videoConverter.ConvertFileAsync(inputFIle);

            if (outputFile != null)
            {
                inputFIle.Delete();
            }

            return(outputFile?.Path);;
        }
예제 #19
0
        private void AddDownloadToList()
        {
            Downloader download = DownloadManager.Instance.Add(
                this.DownloadLocation,
                null,
                this.LocalFile,
                this.Segments,
                false);

            VideoConverter.SetConvertOption(download, this.VideoFormat);

            if (this.StartNow)
            {
                download.Start();
            }
        }
예제 #20
0
        public ChatService(ChatDbContext dbContext,
                           IHubContext <NotificationHub, INotificationClient> hubContext,
                           HttpClient httpClient,
                           LinkGenerator linkGenerator,
                           VideoConverter videoConverter,
                           IHttpContextAccessor httpContextAccessor

                           )
        {
            _dbContext           = dbContext;
            _hubContext          = hubContext;
            _httpClient          = httpClient;
            _linkGenerator       = linkGenerator;
            _httpContextAccessor = httpContextAccessor;
            _videoConverter      = videoConverter;
        }
        public void Convert(string filename, string format)
        {
            var    videoFile = new VideoFile(filename);
            ICodec codec;

            if (format == "MPEG4")
            {
                codec = new Mpeg4Codec();
            }
            else
            {
                codec = new OggCodec();
            }

            var videoConverter = new VideoConverter();

            videoConverter.Convert(videoFile, codec);
        }
예제 #22
0
        public Decoder()
        {
            InitializeComponent();

            Init.Initialize();

            _decoder   = new VideoDecoder();
            _avPacket  = new AVPacket();
            _converter = new VideoConverter(AVPixelFormat.AV_PIX_FMT_BGR24);

            _socket   = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            _endPoint = new IPEndPoint(IPAddress.Any, 1234);
            _socket.Bind(_endPoint);
            _socketThread = new Thread(SocketThread)
            {
                IsBackground = true
            };
            _socketThread.Start();
        }
        public async Task ConvertBeginningDurationPortionTimeSpanTest()
        {
            using var process = VideoToolProcess("convert -f sample.mkv -s 00:00:02 -d 00:00:05");
            process.Start();
            string output = process.StandardOutput.ReadToEnd();

            process.WaitForExit();

            Console.WriteLine("Videotool convert output:");
            Console.WriteLine(output);
            Console.WriteLine("-----------");
            Console.WriteLine();

            Assert.IsTrue(File.Exists("sample.mp4"), "sample.mp4 does not exist.");

            var videoConverter = new VideoConverter();
            var frameCount     = await videoConverter.FetchTotalVideoFrames("sample.mp4");

            Assert.AreEqual(5L * 24, frameCount);
        }
예제 #24
0
            public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser,
                                      IFrame frame, string targetUrl, string targetFrameName,
                                      WindowOpenDisposition targetDisposition, bool userGesture,
                                      IPopupFeatures popupFeatures, IWindowInfo windowInfo,
                                      IBrowserSettings browserSettings, ref bool noJavascriptAccess,
                                      out IWebBrowser newBrowser)
            {
                // Prevent new tab/window
                newBrowser = null;
                // Only load embed video
                VideoConverter converters = new VideoConverter();
                var            converter  = converters.SearchKnownSite(targetUrl);

                if (converter != null)
                {
                    var embeded = converter(targetUrl);
                    chromiumWebBrowser.Load(embeded);
                }
                return(true);
            }
예제 #25
0
        private async Task StopVideoStream()
        {
            if (VideoSource != null)
            {
                DoStopVideoStream();
                await VideoSource.Stop();

                VideoSource.Destroy();
                VideoSource = null;
            }
            if (VideoDepacketizer != null)
            {
                VideoDepacketizer.Destroy();
                VideoDepacketizer = null;
            }
            if (VideoDecoder != null)
            {
                VideoDecoder.Destroy();
                VideoDecoder = null;
            }
            if (ResetVideoPipe != null)
            {
                ResetVideoPipe.Destroy();
                ResetVideoPipe = null;
            }
            if (VideoConverter != null)
            {
                VideoConverter.Destroy();
                VideoConverter = null;
            }
            if (VideoEncoder != null)
            {
                VideoEncoder.Destroy();
                VideoEncoder = null;
            }
            if (VideoPacketizer != null)
            {
                VideoPacketizer.Destroy();
                VideoPacketizer = null;
            }
        }
예제 #26
0
 private void MakingListThread(object obj)
 {
     VideoConverter.MakeTransList(trans_option_, out src_file_list_, out dest_file_list_);
     if (trans_option_.is_flv_to_avi)
     {
         trans_extension_list_.Add("avi");
     }
     if (trans_option_.is_flv_to_wav)
     {
         trans_extension_list_.Add("wav");
     }
     if (trans_option_.is_flv_to_mp3)
     {
         trans_extension_list_.Add("mp3");
     }
     if (trans_option_.is_flv_to_png)
     {
         trans_extension_list_.Add("png");
     }
     BeginInvoke(new MethodInvoker(UpdateList));
 }
예제 #27
0
        static async Task Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Console()
                         .CreateLogger();

            IServiceProvider sp             = BuildServiceProvider();
            BulkMediaUpdater updater        = sp.GetService <BulkMediaUpdater>();
            VideoConverter   videoConverter = sp.GetService <VideoConverter>();
            FaceScanner      faceScanner    = sp.GetService <FaceScanner>();
            ImageHasher      hasher         = sp.GetService <ImageHasher>();

            //await videoConverter.GenerateVideosAsync(default);

            //await updater.UpdateMediaAISummaryAsync(default);

            await hasher.HashAsync();

            //await faceScanner.RunAsync(default);
        }
예제 #28
0
 private Task StopVideoStream()
 {
     if (VideoDepacketizer != null)
     {
         VideoDepacketizer.Destroy();
         VideoDepacketizer = null;
     }
     if (VideoDecoder != null)
     {
         VideoDecoder.Destroy();
         VideoDecoder = null;
     }
     if (VideoConverter != null)
     {
         VideoConverter.Destroy();
         VideoConverter = null;
     }
     if (ResetVideoPipe != null)
     {
         ResetVideoPipe.Destroy();
         ResetVideoPipe = null;
     }
     if (VideoEncoder != null)
     {
         VideoEncoder.Destroy();
         VideoEncoder = null;
     }
     if (VideoPacketizer != null)
     {
         VideoPacketizer.Destroy();
         VideoPacketizer = null;
     }
     if (VideoSink != null)
     {
         VideoSink.Destroy();
         VideoSink = null;
     }
     return(Task.CompletedTask);
 }
예제 #29
0
    // Use this for initialization
    void Start()
    {
        Screen.autorotateToPortrait       = true;
        Screen.autorotateToLandscapeLeft  = true;
        Screen.autorotateToLandscapeRight = true;

        Screen.orientation = ScreenOrientation.AutoRotation;

        // Use screen size as image size
        if (Application.platform != RuntimePlatform.OSXEditor)
        {
            _imageWidth  = Screen.width;
            _imageHeight = Screen.height;

            _videoConverter = (VideoConverter)gameObject.GetComponent("VideoConverter");
        }

        int i = UnityEngine.Random.Range(1, 4);

        switch (i)
        {
        case 1:
            RotateLeft();
            break;

        case 2:
            RotateRight();
            break;

        case 3:
            RotateDown();
            break;

        case 4:
            RotateUp();
            break;
        }
    }
예제 #30
0
        public void OnClientVideoReceived(I420AVideoFrame frame)
        {
            if (DateTime.Now > this.lastVideoSentToClientTimeUtc + TimeSpan.FromMilliseconds(33))
            {
                try
                {
                    this.lastVideoSentToClientTimeUtc = DateTime.Now;

                    byte[] i420Frame = new byte[frame.width * frame.height * 12 / 8];
                    frame.CopyTo(i420Frame);

                    byte[] nv12Frame = VideoConverter.I420ToNV12(i420Frame);

                    VideoFormat sendVideoFormat = VideoFormatUtil.GetSendVideoFormat((int)frame.height, (int)frame.width);
                    var         videoSendBuffer = new VideoSendBuffer(nv12Frame, (uint)nv12Frame.Length, sendVideoFormat);
                    this.Call.GetLocalMediaSession().VideoSocket.Send(videoSendBuffer);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
예제 #31
0
    public void extractFile(string file)
    {
        extracted = false;
        string[] dir      = file.Split(System.IO.Path.DirectorySeparatorChar);
        string   filename = dir [dir.Length - 1].Split('.') [0];

        string exportLocation = getCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "Games" + System.IO.Path.DirectorySeparatorChar + filename;

        ZipUtil.Unzip(file, exportLocation);

        foreach (string f in System.IO.Directory.GetFiles(exportLocation))
        {
            if (!f.Contains(".xml"))
            {
                System.IO.File.Delete(f);
            }
        }

        string[] tmp;
        foreach (string f in System.IO.Directory.GetDirectories(exportLocation))
        {
            tmp = f.Split(System.IO.Path.DirectorySeparatorChar);
            if (tmp[tmp.Length - 1] != "assets" && tmp[tmp.Length - 1] != "gui")
            {
                System.IO.Directory.Delete(f, true);
            }
        }

        VideoConverter converter = new VideoConverter();

        foreach (string video in System.IO.Directory.GetFiles(exportLocation + "/assets/video/"))
        {
            converter.Convert(video);
        }

        extracted = true;
    }
예제 #32
0
    public void extractFile(string file)
    {
        extracted = false;
        string[] dir = file.Split (System.IO.Path.DirectorySeparatorChar);
        string filename = dir [dir.Length - 1].Split ('.') [0];

        string exportLocation = getCurrentDirectory () + System.IO.Path.DirectorySeparatorChar + "Games" + System.IO.Path.DirectorySeparatorChar + filename;

        ZipUtil.Unzip (file, exportLocation);

        foreach(string f in System.IO.Directory.GetFiles(exportLocation)){
            if (!f.Contains (".xml"))
                System.IO.File.Delete (f);
        }

        string[] tmp;
        foreach(string f in System.IO.Directory.GetDirectories(exportLocation)){
            tmp = f.Split (System.IO.Path.DirectorySeparatorChar);
            if (tmp[tmp.Length-1] != "assets" && tmp[tmp.Length-1] != "gui")
                System.IO.Directory.Delete (f,true);
        }

        VideoConverter converter = new VideoConverter();
        foreach (string video in System.IO.Directory.GetFiles(exportLocation + "/assets/video/"))
        {
            converter.Convert(video);
        }

            extracted = true;
    }
        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {

                fileSource = new FileVideoSource(openFileDialog1.FileName);
                textBoxVideoPath.Text = openFileDialog1.FileName;
                textBoxVideoPath.Enabled = false;
                VideoConverter vdc = new VideoConverter();
                path = openFileDialog1.FileName;

            }
        }