Creating an AVI in memory with C++
        
The following example demonstrates how an avi file is completely created in memory.

/*
   MakeAviInMemory.cpp

An example on how to use Avi.cpp

Copyright (c) 2004, 2005 René Nyffenegger

This source code is provided 'as-is', without any express or implied
   warranty. In no event will the author be held liable for any damages
   arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
   including commercial applications, and to alter it and redistribute it
   freely, subject to the following restrictions:

1. The origin of this source code must not be misrepresented; you must not
      claim that you wrote the original source code. If you use this source code
      in a product, an acknowledgment in the product documentation would be
      appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be
      misrepresented as being the original source code.

3. This notice may not be removed or altered from any source distribution.

René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/

#include <windows.h>
#include "avi.h"

#include <iostream>
#include <sstream>

#include "MemoryDC.h"
#include "DibSection.h"
#include "Color.h"
#include "Font.h"

int main() {
  const float frames_per_second = 24.0;

Avi a("InMemory.avi",static_cast<int>(1000.0/frames_per_second),0);

MemoryDC memory_dc;

for (int i=0; i<5*frames_per_second; i++) {  
    DibSection dib_section(200, 200);
    memory_dc.Select(dib_section);
     // Set up compression just before the first frame
     if (i==0) {
       //AVICOMPRESSOPTIONS opts;
       //ZeroMemory(&opts,sizeof(opts));
       //opts.fccHandler=mmioFOURCC('d','i','v','x');
       //SetAviVideoCompression(hbm,0/*&opts*/,true,0);
       HRESULT r = a.compression(dib_section, 0 /*&opts*/, true, 0);
       char buf [200];
       if (r != S_OK) {
         FormatAviMessage(r, buf, 200);
         std::cout << "compression: " << buf << std::endl;
         return -1;
       }
    }

memory_dc.DrawOpaque(false);
    memory_dc.TextColor(Color(0,0,255));
    memory_dc.Select(Font("Arial", 100));
 
    STD_SSTR s;
    s<<i;
    memory_dc.Text(50,50,s.str().c_str());

HRESULT r =a.add_frame(dib_section);

char buf [200];
    if (r != S_OK) {
      FormatAviMessage(r, buf, 200);
      std::cout << buf << std::endl;
    }
  }
}

Creating an AVI in memory with C++的更多相关文章

  1. WCF Windows Service Using TopShelf and ServiceModelEx z

    http://lourenco.co.za/blog/2013/08/wcf-windows-service-using-topshelf-and-servicemodelex/ There are ...

  2. SPFILE 、PFILE 的全面解读

    这里先阐述一下数据库的启动过程: 1.      启动实例/例程(nomount状态)时,读取参数文件(文本文件PFILE 或服务器参数文件SPFILE),分配SGA.启动后台进程.打开告警文件及后台 ...

  3. udp协议的数据接收与发送的代码

    我想基于lwIP协议中的UDP协议,用单片机做一个服务器,接受电脑的指令然后返回数据.以下是我的代码 /************************************************ ...

  4. 利用ZYNQ SOC快速打开算法验证通路(6)——LWIP实现千兆TCP/IP网络传输

    一.前言 之前ZYNQ与PC之间的网络连接依赖于外接硬件协议栈芯片,虽然C驱动非常简单,但网络带宽受限.现采用LWIP+PS端MAC控制器+PHY芯片的通用架构.关于LWIP库,已经有很多现成的资料和 ...

  5. C# to IL 6 Reference and Value Types(引用类型和值类型)

    An interface is a reference type, in spite of the fact that it has no code at all. Thus, wecannot in ...

  6. centos7.5安装minikube kubernetes

    前提:已安装centos7.5安装VirtualBox Minikube是什么?Minikube是一种方便在本地运行Kubernetes的工具. Minikube 是可以在VM中运行单节点的Kuber ...

  7. FPGA内部RAM的初始化

    Altera的RAM初始化文件格式是mif和hex. QuartusII自带的RAM初始化工具很方便产生初始化文件. Xilinx的RAM初始化文件格式是coe, 在vivado中软件会将coe文件变 ...

  8. GPU Command Buffer

    For Developers‎ > ‎Design Documents‎ > ‎ GPU Command Buffer This are mostly just notes on the ...

  9. minikube国内在线部署体验

    问题描述: 快速学习k8s的各个组件的作用及yml的编写,minikube很适合. how to install Minikube, a tool that runs a single-node Ku ...

随机推荐

  1. 【BZOJ】1610: [Usaco2008 Feb]Line连线游戏(几何)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1610 两种做法,一种计算几何,一种解析几何,但是计算几何的复杂度远远搞出解析集合(虽然精度最高) 计 ...

  2. hdu 2857:Mirror and Light(计算几何,点关于直线的对称点,求两线段交点坐标)

    Mirror and Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  3. 设置两个WdatePicker的开始时间小于结束时间,结束时间大于开始时间

    contract_start_date_id为开始时间ID contract_end_date_id为结束时间ID $("#contract_start_date_id").bin ...

  4. Angular 组件与模板 - 属性指令

    指令概览 在 Angular 中有三种类型的指令: 组件 — 拥有模板的指令 结构型指令 — 通过添加和移除 DOM 元素改变 DOM 布局的指令 属性型指令 — 改变元素.组件或其它指令的外观和行为 ...

  5. .Net CCNet C#6.0 自动化编译问题解决

    一.问题描述 由于C#6.0一些新的语法特性,导致先前部署的CCNet持续集成平台出现问题,无论是手动还是命令行均不能编译.   二.解决方案 1.下载BuildTools_Full.exe,地址:h ...

  6. Splash界面完美实现

    Flash闪烁界面的实现原理 1.首先 new一个数组里面放一些Random图片 private int[] drawables = new int[]{R.drawable.a,R.adable.b ...

  7. 如何改变placeholder的样式

    input::-webkit-input-placeholder { color: #B2B2B2; } input:-moz-placeholder { color: #B2B2B2; } inpu ...

  8. Linux Kernel 4.7版本发布

    导读 在经历了长达一周的惬意假日时光,大神Linus Torvalds宣布面向所有GNU/Linux操作系统发布Linux Kernel 4.7.Linux 4.7内核的研发历经2个多月,自今年5月2 ...

  9. IOS 十位数0补齐

    NSCalendar *calendar = [NSCalendar currentCalendar]; unsigned unitFlags = NSYearCalendarUnit | NSMon ...

  10. nexus的pom配置

    <groupId>com .sms</groupId><artifactId>sms </artifactId><packaging>pom ...