📄 mfsname.cc
字号:
const char *help = "\progname: mfsname.cc\n\code2html: This program reads a video file with timecode enocded in the frames and print the timecode-derived name to stdout.\n\\n\ This program is designed to be called by a perl script to rename avi\n\ according to a standard convention. From within perl, it is called\n\ as follows:\n\\n\ `mfsname $sessionDir/$dir/$filename` =~ /(^T.*_T.*$)/m;\n\\n\ in order to filter out any junk debugging statements that various\n\ libraries might print out before the actual name is printed.\n\\n\version: Torch3 vision2.0, 2002-2005\n\(c) Pierre Wellner (wellner@idiap.ch) and Sebastien Marcel (marcel@idiap.ch)\n";// system#include <sys/stat.h> // image#include "ImageRgb.h"#include "ImageGray.h"// video#include "ffmpegVideoFile.h"#include "vitcTimeCode.h"using namespace Torch;/*------------------------------------------------------------------------ * return pointer to file extension including the "." ------------------------------------------------------------------------*/char *GetFileExtension(char *pz){ int i; if (pz == 0) return ""; i = strlen(pz); while ((i >= 0) && (pz[i] != '.')) i--; if (i >= 0) return &pz[i]; else return ""; } // end GetFileExtensionint main(int argc, char *argv[]){ char *filename_in = ""; char *pzExtension = NULL; unsigned numberOfFrames = 0; char pzNewName[1000] = ""; struct stat statbuf; if (argc < 2) { fprintf(stderr, "usage: %s <video avi filename>\n", argv[0]); printf("%s", help); return -1; } filename_in = argv[1]; if ( 0 != stat(filename_in, &statbuf)) { fprintf(stderr, "ERROR: bad filename \"%s\"\n", filename_in); exit (-1); } pzExtension = GetFileExtension(filename_in); // ffmpegVideoFile *movie = new ffmpegVideoFile(); movie->open(filename_in); numberOfFrames = movie->getnframes(); if (numberOfFrames <= 0) { fprintf(stderr, "ERROR: bad filename \"%s\"\n", filename_in); delete movie; exit (-1); } if(movie->read() != true) { delete movie; return -1; } int width = movie->getwidth(); int height = movie->getheight(); ImageRgb *image = new ImageRgb(width, height); ImageGray *grayimage = new ImageGray(width, height); vitcTimeCode *timecode = new vitcTimeCode(width, height); grayimage->copyFrom(width, height, movie->pixmap, "rgb"); timecode->reset(grayimage->pixmap); sprintf(pzNewName,"T%02d%02d%02d.%03d_T%02d%02d%02d.%03d", timecode->hh(), // hours timecode->mm(), // minutes timecode->ss(), // seconds timecode->ff() * (1000 / 25), // milliseconds from frames numberOfFrames / (25 * 60 * 60), // hours (numberOfFrames / (25 * 60)) % 60, // minutes (numberOfFrames / 25) % 60, // seconds (numberOfFrames % 25) * (1000 / 25) // milliseconds ); // cleanup movie->close(); delete image; delete grayimage; printf("%s\n", pzNewName); return 0; } // end main()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -