25 #include <Utils/Param.hh>
26 #include <Utils/IOUtils.hh>
27 #include <VideoSource/VideoSource_FFmpeg.hh>
32 int main(
int argc,
char** argv) {
39 "path to the video file",
"",
'i');
41 int* maxNumberOfFrames = params.
AddParamInt(
"maxNumberOfFrames",
42 "maximal number of frames",INT_MAX, 0, INT_MAX,
'n');
44 if (!IOUtils::ParseCommandLineEvalHelp(params, argc, argv))
47 cout <<
"getting " << *maxNumberOfFrames << endl;
54 if (decoder.
OpenDevice(videoFile->c_str()) < 0 ) {
62 string dir, base, suffix;
63 FileHandling::SplitName(*videoFile, dir, base, suffix);
67 unsigned int numberOfImageSaved = 0;
70 while (res == 0 && (
int)numberOfImageSaved < *maxNumberOfFrames) {
72 cout <<
"got frame " << numberOfImageSaved << endl;
74 if(res != 0) BIASERR(
"Error:"<<decoder.
GetError());
75 string imageName = base+
"_"+FileHandling::LeadingZeroString(numberOfImageSaved, 4) +
".png";
76 ImageIO::Save(imageName,image);
78 numberOfImageSaved ++;
virtual int InitImage(BIAS::ImageBase &Image)
virtual int OpenDevice(const char *filename)
Open video file.
virtual int GrabSingle(Camera< unsigned char > &image)
Get the next frame from the video file.
Simple video decoding of video files using FFmpeg library.
std::string GetError()
Get the last error message.
virtual int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)
This class Param provides generic support for parameters.
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)