您的位置:首页 > 新闻 > 会展 > 秦皇岛网络推广公司_北京东易日盛装饰公司_在线seo诊断_自己建站的网站

秦皇岛网络推广公司_北京东易日盛装饰公司_在线seo诊断_自己建站的网站

2024/10/17 12:32:46 来源:https://blog.csdn.net/whf227/article/details/142246742  浏览:    关键词:秦皇岛网络推广公司_北京东易日盛装饰公司_在线seo诊断_自己建站的网站
秦皇岛网络推广公司_北京东易日盛装饰公司_在线seo诊断_自己建站的网站

        EmguCV是opencv的C#库,该库可以用来处理图像,还可以处理视频。以下是视频合并的方法,不过效率比较低。

/// <summary>
  /// 合并多个视频为新的视频()
  /// </summary>
  /// <param name="videoFiles"></param>
  /// <param name="newPath"></param>
  public bool MergeVideos(string[] videoFiles, string newPath)
  {
      try
      {
          VideoCapture vc = new VideoCapture(videoFiles[0]);
          int fps = (int)vc.GetCaptureProperty(CapProp.Fps);
          int width = (int)vc.GetCaptureProperty(CapProp.FrameWidth);//长
          int height = (int)vc.GetCaptureProperty(CapProp.FrameHeight);//宽
          int totalFrameCount = (int)vc.GetCaptureProperty(CapProp.FrameCount);//总帧数
          int fourcc = VideoWriter.Fourcc('M','J','P','G');
          VideoWriter videoWriter = new VideoWriter(newPath, fourcc, fps, new Size(width, height),true);
          int n = 0;
          foreach (string file in videoFiles)
          {
              if (n >= 1)
              {
                  vc.Dispose();
                  vc = new VideoCapture(file);
              }
              if (vc.IsOpened)
              {
                  int i = 0;
                  while (i < totalFrameCount)
                  {
                      i++;
                      Mat mat = new Mat();
                      vc.Read(mat);
                      if (mat != null)
                          videoWriter.Write(mat);
                  }
              }
              n++;
          }
          videoWriter.Dispose();
      }
      catch (Exception ex)
      {
          return false;
      }
      return true;
  }

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com