Exemplo n.º 1
0
        /// <summary>
        /// 开始转换
        /// </summary>
        /// <param name="inputFile">需转换的路径,转换为同名但后缀名不同的视频</param>
        /// <returns></returns>
        public OutputPackage ConvertToFLV(string vpath)
        {
            VideoFile     vf = new VideoFile(function.VToP(vpath));
            OutputPackage oo = ConvertToFLV(vf, vpath);

            return(oo);
        }
Exemplo n.º 2
0
        //The actually important code, rather than an overload.
        public OutputPackage ConvertToFLV(VideoFile input, string fname)
        {
            fname = Path.GetFileNameWithoutExtension(fname);
            if (!input.infoGathered)
            {
                GetVideoInfo(input);
            }
            OutputPackage ou      = new OutputPackage();
            string        imgname = fname + ".jpg";
            string        flvname = fname + ".flv";
            int           secs;

            secs = (int)Math.Round(TimeSpan.FromTicks(input.Duration.Ticks / 3).TotalSeconds, 0);

            string finalpath = Path.Combine(this.WorkingPath, imgname);
            string Params    = string.Format("-i {0} {1} -vcodec mjpeg -ss {2} -vframes 1 -an -f rawvideo", input.Path, finalpath, secs);//截图

            //string output = RunProcess(Params);
            //ou.RawOutput = output;
            //if (File.Exists(finalpath))//生成预览图
            //{
            //    //load that file into our output package and attempt to delete the file
            //    //since we no longer need it.
            //    //ou.PreviewImage = LoadImageFromFile(finalpath);
            //    //File.Delete(finalpath);
            //}
            //else
            //{
            //    Params = string.Format("-i {0} {1} -vcodec mjpeg -ss {2} -vframes 1 -an -f rawvideo", input.Path, finalpath, 1);
            //    output = RunProcess(Params);
            //    ou.RawOutput = output;
            //    if (File.Exists(finalpath))
            //    {
            //        //ou.PreviewImage = LoadImageFromFile(finalpath);
            //        //File.Delete(finalpath);
            //    }
            //}

            finalpath = Path.Combine(this.WorkingPath, flvname);
            Params    = string.Format("-i {0} -y -ar 22050 -ab 64 -f flv {1}", input.Path, finalpath); //转换文件为flv
            string output = RunProcess(Params);                                                        //返回的提示信息

            if (File.Exists(finalpath))
            {
                ou.VideoStream = LoadMemoryStreamFromFile(finalpath);
                //File.Delete(finalpath);
            }
            else
            {
                function.WriteErrMsg("转换失败,原因:" + output);
            }
            ou.VPath = function.PToV(finalpath);
            return(ou);
        }
Exemplo n.º 3
0
        protected void Conver_Btn_Click(object sender, EventArgs e)
        {
            string        fpath = Server.MapPath(Source_T.Text);
            OutputPackage model = conver.ConvertToFLV(Source);

            videoMod       = videoBll.SelReturnModel(Mid);
            videoMod.VName = Path.GetFileName(model.VPath);
            videoMod.VPath = model.VPath;
            videoBll.UpdateByID(videoMod);
            Source = model.VPath;
            function.WriteSuccessMsg("转换完成!");
        }
Exemplo n.º 4
0
        public OutputPackage ConvertToFLV(MemoryStream inputFile, string Filename)
        {
            string     tempfile = Path.Combine(this.WorkingPath, System.Guid.NewGuid().ToString() + Path.GetExtension(Filename));
            FileStream fs       = File.Create(tempfile);

            inputFile.WriteTo(fs);
            fs.Flush();
            fs.Close();
            GC.Collect();

            VideoFile     vf = new VideoFile(tempfile);
            OutputPackage oo = ConvertToFLV(vf, Filename);

            File.Delete(tempfile);
            return(oo);
        }
Exemplo n.º 5
0
 private void Madegifmadeend(object sender, OutputPackage package)
 {
     this.progressBar1.Value = Index;
     ((itemMovie)listView.Items[Index].Tag).Thumbs = (Image)Image.FromStream(package.VideoStream).Clone();
     pictureBox1.Image = ((itemMovie)listView.Items[Index].Tag).Thumbs;
     listView.Items[Index].SubItems[4].Text = "End";
     Index++;
     if (Index <= listView.Items.Count - 1)
     {
         ThrowProcessMakeGif();
     }
     else
     {
         btnAceptar.Enabled = true; //desabilitamos.
         btnAbrir.Enabled   = true; //desabilita abrir ficheros
     }
 }
Exemplo n.º 6
0
 protected override void Save()
 {
     OutputPackage?.Save();
     OutputPackage?.Stream.Dispose();
 }
Exemplo n.º 7
0
 private void MadeGif(object sender, OutputPackage package)
 {
     this.BeginInvoke(new Converter.MakeFilmGifHandler(Madegifmadeend), new object[] { sender, package });
 }
Exemplo n.º 8
0
        public void CreateVideoThumbnails(VideoFile input)
        {
            if(!input.infoGathered)
            {
                GetVideoInfo(input);
            }
            OutputPackage ou = new OutputPackage();

            //set up the parameters for getting a previewimage
            string filename;
            string finalpath;
            string Params;
            int secs;
            double[] previewPercentages = new double[] { .05, .15, .25, .35, .45, .55, .65, .75, .85, .95 };

            foreach(double previewPercentage in previewPercentages)
            {
                secs = (int)Math.Round(TimeSpan.FromTicks((long)(input.Duration.Ticks * previewPercentage)).TotalSeconds, 0);

                filename = string.Format("{0}.jpg", secs.ToString());
                finalpath = Path.Combine(this.WorkingPath, filename);
                Params = string.Format("-i {0} -ss {1} -vcodec mjpeg -vframes 1 -an {2} -f rawvideo", input.Path, secs, finalpath);

                this.RunProcess(Params);
            }
        }
Exemplo n.º 9
0
    /// <summary>
    /// 请求MCU信息
    /// </summary>
    public void RequestHardwareInfo()
    {
#if MOBILE_EDITION
        return;
#endif
        if (!IsOpen())
            return;
        OutputPackage pack = new OutputPackage(OutputPackCmd.RequestMCUInfo,0);

        Monitor.Enter(mSendPack_ThreadLock);
        mPackToSendMT.Add(pack);
        Monitor.Exit(mSendPack_ThreadLock); 
    }