📄 aviduration.cc
字号:
const char *help = "\progname: aviduration.cc\n\code2html: This program reads a video file and returns the duration in seconds.\n\version: Torch3 vision2.0, 2004-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "rgbRawVideoFile.h"#include "ffmpegVideoFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){ char *input_filename; bool verbose; bool ffmpeg; // Construct the command line CmdLine cmd; cmd.setBOption("write log", false); // Put the help line at the beginning cmd.info(help); cmd.addText("\nArguments:"); cmd.addSCmdArg("input filename", &input_filename, "video filename"); cmd.addText("\nOptions:"); cmd.addBCmdOption("-verbose", &verbose, false, "verbose"); cmd.addBCmdOption("-ffmpeg", &ffmpeg, false, "ffmpeg"); cmd.read(argc, argv); VideoFile *video = NULL; if(ffmpeg) video = new ffmpegVideoFile(); else video = new rgbRawVideoFile(); int duration = 0; if(video->open(input_filename) == true) { int width = video->getwidth(); int height = video->getheight(); real fps = video->getframerate(); real brate = video->getbitrate(); int nframes = video->getnframes(); char *codec = video->getcodec(); duration = (int) (nframes / fps); if(verbose) { print("width = %d\n", width); print("height = %d\n", height); print("nframes = %d\n", nframes); print("fps = %g\n", fps); print("bitrate = %g\n", brate); print("duration = %d\n", duration); print("codec = [%s]\n", ((strlen(codec)==0)? "RGB": codec)); } video->close(); } delete video; exit(duration);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -