A script for splitting videos using ffmpeg v2

 //author:hnrayer@gmail.com
#if _MSC_VER
#define inline __inline
#endif
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/log.h>
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable : 4996)
int main(int argc, char **argv)
{
AVFormatContext *piFormatCtx = NULL;
//the number of segments
char *pszSegments = NULL;
int   i_segments;       
//the duration of each segment
int sum_secs = 0;
int step = 0;
char szcmd[128];//command
char *pszFullname;
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
if (argc < 3)
{
printf("usage: ffsplit infile num [num:the number of segments]\n");
return -1;
}
pszSegments = argv[2];
i_segments = atoi(pszSegments);
//Register all formats and codecs
av_register_all();
//Open video file
if(avformat_open_input(&piFormatCtx, argv[1], NULL, NULL) != 0)
{
return -1; 
}
//Retrieve stream information
if(avformat_find_stream_info(piFormatCtx, NULL) < 0)
{
return -1; 
}
//print the info of duration
av_log(NULL, AV_LOG_INFO, "  Duration: ");
if (piFormatCtx->duration != AV_NOPTS_VALUE)
{
int hours, mins, secs, us;
int64_t duration = piFormatCtx->duration + 5000;  
secs = duration / AV_TIME_BASE;
us = duration % AV_TIME_BASE; 
mins = secs / 60;
secs %= 60;
hours = mins / 60;
mins %= 60;
av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d\n", hours, mins, secs, (100 * us) / AV_TIME_BASE); 
sum_secs = hours*60*60 + mins*60 +secs;
else 
{
av_log(NULL, AV_LOG_INFO, "N/A");
}
step = sum_secs / i_segments;
pszFullname = piFormatCtx->filename;
_splitpath(pszFullname, drive, dir, fname, ext);
/
sprintf(szcmd, "ffmpeg -i %s -codec copy -map 0 -f segment -segment_time %d %s_%%03d%s", argv[1], step, fname, ext);
puts(szcmd);
system(szcmd);
//Close the video file
avformat_close_input(&piFormatCtx);
return 0;
}

转载于:https://www.cnblogs.com/elesos/archive/2013/04/08/3008523.html

Raize Components是Delphi和C++Builder下的用户界面组件,拥有超过125种通用原生VCL控件集合。此次发布的Raize Components v6.1版本新增加IDE支持和帮助文档,以及其他一些组件更新。 Raize组件, Delphi和C + + Builder的是一个用户界面的设计系统。在它的中心是一个集合超过125个通用的原生VCL控件。内置技术的基础上,第一次创建超过15年前,这些高品质的组件为开发人员提供无与伦比的力量和灵活性而不牺牲易于使用。除了核心的控件集, Raize组件包括超过100个组件设计师专注于简化用户界面开发。现在比以往任何时候都多,开发人员使用Raize组件来构建复杂的用户界面,在更短的时间内,以较少的努力。 Raize组件6的主要焦点是在新的VCL功能已被添加到Embarcadero公司的RAD Studio的。具体来说, 64位的VCL支持和很酷的新VCL样式支持。不同于其他版本的RAD Studio只需重新编译现有代码库提供了一套新的日间护理单位和包,有很多低层次的变化VCL的。例如,许多控件顺利迁移到64位,但许多其他需要低层次的修改。此外, Raize组件的每一个控制受新的VCL样式。每个控件的显示代码,需要进行大幅修改,全力支持VCL样式时,他们。已经做了大量的工作,但我们确信你会发现最终的结果真的很酷! 还有其他的改进和修正Raize组件6 ,但64位和VCL样式的支持是主要的新功能。 Raize组件6肯定利用RAD Studio和得到最RC6的,你需要的RAD Studio XE2或更高版本。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值