zoukankan      html  css  js  c++  java
  • C# 下写入视频的简单实现

    很多时候我们要读写视频,C#读视频(对视频解码)网上的例子很多,然而写视频(对视频编码)的例子却很少,也很少能搜索到有用的信息。下面是使用Aforge.Net写视频的简单方案。

    Aforge.Net 是一个 C# 版的图像和计算机视觉库,网站 http://www.aforgenet.com/ 。下载安装。Aforge.Net 有一个子项目 AForge.Video.FFMPEG 对 ffmpeg 的视频操作进行了封装。

    添加对 AForge.Video.FFMPEG.dll, AForge.Video.dll和 AForge.dll 三个 dll 的引用,Aforge.Net 的文档中提供了个写视频的例子:

    int width  = 320;
    int height = 240;

    // create instance of video writer
    VideoFileWriter writer = new VideoFileWriter( );
    // create new video file
    writer.Open( "test.avi", width, height, 25, VideoCodec.MPEG4 );
    // create a bitmap to save into the video file
    Bitmap image = new Bitmap( width, height, PixelFormat.Format24bppRgb );
    // write 1000 video frames
    for ( int i = 0; i < 1000; i++ )
    {
        image.SetPixel( i % width, i % height, Color.Red );
        writer.WriteVideoFrame( image );
    }
    writer.Close( );

    由于 Aforge.Net 封装的是 ffmpeg,因此需要将 ffmpeg 的几个dll(AForge.NET\Framework\Externals\ffmpeg\bin路径下的全部dll)放在执行路径下。

    如此简单 …… </ p>

  • 相关阅读:
    POJ 3071 概率DP
    BZOJ 2427 /HAOI 2010 软件安装 tarjan缩点+树形DP
    POJ 1155 树形DP
    POJ 3252 组合数学?
    POJ 3641 快速幂
    POJ 3180 Tarjan
    POJ 3185 DFS
    POJ 3260 DP
    POJ 2392 DP
    99. Recover Binary Search Tree
  • 原文地址:https://www.cnblogs.com/xiaotie/p/2776519.html
Copyright © 2011-2022 走看看