Creating an AVI in memory with C++
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++的更多相关文章
- WCF Windows Service Using TopShelf and ServiceModelEx z
http://lourenco.co.za/blog/2013/08/wcf-windows-service-using-topshelf-and-servicemodelex/ There are ...
- SPFILE 、PFILE 的全面解读
这里先阐述一下数据库的启动过程: 1. 启动实例/例程(nomount状态)时,读取参数文件(文本文件PFILE 或服务器参数文件SPFILE),分配SGA.启动后台进程.打开告警文件及后台 ...
- udp协议的数据接收与发送的代码
我想基于lwIP协议中的UDP协议,用单片机做一个服务器,接受电脑的指令然后返回数据.以下是我的代码 /************************************************ ...
- 利用ZYNQ SOC快速打开算法验证通路(6)——LWIP实现千兆TCP/IP网络传输
一.前言 之前ZYNQ与PC之间的网络连接依赖于外接硬件协议栈芯片,虽然C驱动非常简单,但网络带宽受限.现采用LWIP+PS端MAC控制器+PHY芯片的通用架构.关于LWIP库,已经有很多现成的资料和 ...
- 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 ...
- centos7.5安装minikube kubernetes
前提:已安装centos7.5安装VirtualBox Minikube是什么?Minikube是一种方便在本地运行Kubernetes的工具. Minikube 是可以在VM中运行单节点的Kuber ...
- FPGA内部RAM的初始化
Altera的RAM初始化文件格式是mif和hex. QuartusII自带的RAM初始化工具很方便产生初始化文件. Xilinx的RAM初始化文件格式是coe, 在vivado中软件会将coe文件变 ...
- GPU Command Buffer
For Developers > Design Documents > GPU Command Buffer This are mostly just notes on the ...
- minikube国内在线部署体验
问题描述: 快速学习k8s的各个组件的作用及yml的编写,minikube很适合. how to install Minikube, a tool that runs a single-node Ku ...
随机推荐
- 【转】虚拟串口VSPM解决串口编程问题
通过串口调试软件 UartAssist.exe 和虚拟串口软件 VSPM,可以解决串口编程时没用硬件调试的问题,通过VSPM虚拟出串口设备,让程序发送信息到 VSPM 设备后通过 UartAssist ...
- 小谈js原型链和继承
原型(prototype)在js中可是担当着举足轻重的作用,原型的实现则是在原型链的基础上,理解原型链的原理后,对原型的使用会更加自如,也能体会到js语言的魅力. 本文章会涉及的内容 原型及原型对象 ...
- WPF 隧道路由事件
阅读本文前,请先了解 冒泡路由事件:http://www.cnblogs.com/andrew-blog/p/WPF_BubbledEvent.html 隧道路由事件的工作方式和冒泡路由事件相同,但方 ...
- Hibernate_day03--课程安排_表之间关系_一对多操作
Hibernate_day03 上节内容 今天内容 表与表之间关系回顾(重点) Hibernate的一对多操作(重点) 一对多映射配置(重点) 一对多级联操作 一对多级联保存 一对多级联删除 一对多修 ...
- Javascript实现图片的预加载的完整实现
图片预加载是web开发中一种应用相当广泛的技术,比如我们在做图片翻转显示等特效的时候,为了让图片在转换的时候不出现等待,我们最好是先让图片下载到本地,然后在继续执行后续的操作.今天我们将来实现一个完整 ...
- iOS 引导页面启动一次
#import "AppDelegate.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)a ...
- Android StaggeredGrid 加下拉刷新功能 PullToRefresh
https://github.com/etsy/AndroidStaggeredGrid 用的github上面提供瀑布流,继承于abslistview,回收机制不错,并且提供了OnScrollLis ...
- MySQL安装时出现Apply Security Settings错误的解决办法
windows版mysql安装执行程序下载地址: https://dev.mysql.com/downloads/file/?id=473605 点击下面的No thanks, just start ...
- 170327、Java微信支付中的扫码支付
微信支付现在已经变得越来越流行了,随之也出现了很多以可以快速接入微信支付为噱头的产品,不过方便之余也使得我们做东西慢慢依赖第三方,丧失了独立思考的能力,这次打算分享下我之前开发过的微信支付. 一 H5 ...
- Javascript-const 常量
const 常量 常量是块级作用域,很像使用 let语句定义的变量.常量的值不能通过重新赋值来改变,并且不能重新声明. 此声明创建一个常量,其作用域可以是全局或本地声明的块. 与var变量不同,全局常 ...