Пример #1
0
        /// <summary>
        /// 向前连接视频文件
        /// </summary>
        /// <param name="file">目标文件</param>
        /// <returns></returns>
        public Video PushFront(Video file, Quality Quality)
        {
            var src = new List <string>();

            src.Add(file._Source);
            src.Add(_Source);
            var fname = Path.GetTempPath() + "pomelo_" + Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(_Source);

            try
            {
                MediaHelper.Concat(src, fname, Quality);
            }
            catch
            {
                return(null);
            }
            var ret = new Video(fname);

            ret.IsTemp = true;
            return(ret);
        }
Пример #2
0
        /// <summary>
        /// 抽取整个影片帧
        /// </summary>
        /// <param name="timeoff">时间(秒)</param>
        /// <returns></returns>
        public List <Image> GetFrames(int timeoff = 1)
        {
            var result = new List <Image>();

            for (var i = 0; i < Info.Duration.TotalSeconds; i += timeoff)
            {
                try
                {
                    var fname = Path.GetTempPath() + "pomelo_" + Guid.NewGuid().ToString().Replace("-", "") + ".jpg";
                    System.IO.File.WriteAllBytes(fname, MediaHelper.GetFrame(_Source, i));
                    var frame = new Image(fname);
                    frame.IsTemp = true;
                    result.Add(frame);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("System caught an exception:");
                    System.Diagnostics.Debug.WriteLine(e.ToString());
                }
            }
            return(result);
        }