//////////////////////////////////////////////////// //! rcsid="$Id: exVideo.cc,v 1.22 2000/11/24 16:11:02 ees1wc Exp $" #include "amma/Video.hh" #include "amma/YUVValue.hh" #include "amma/Filename.hh" #include "amma/Option.hh" #include int main (int argc, char* argv[]) { OptionC opt(argc, argv); opt.Comment( "Reads image sequence in one format & writes it to another; " "file formats are determined by the file names (see the class documentation)\n\n" "Examples:\n\n" " exVideo fred.qcif jim.ppm\n\n" "- reads in stream of YUV images from \"fred.qcif\"\n" "- writes them to a set of ppm image files jim0.ppm jim1.ppm ....\n\n" " exVideo fred.qcif jim%3d.ppm\n\n" "- reads in stream of YUV images from \"fred.qcif\"\n" "- writes them to a set of ppm image files jim000.ppm jim001.ppm ....\n\n" " exVideo fred.yuv jim.cif\n\n" "- reads YUV images from the Abekas format files fred000.yuv fred001.yuv ....\n" "- writes them to a cif file \"jim.cif\"\n\n" " exVideo /vol/vssp/video/database/abekas/calender/cal.yuv - -n 1 -s 6 -of ppm | xv -\n\n" "- reads file cal006.yuv and pipes it into xv\n\n" "Note that the images are *not* scaled; they are truncated / padded to fit.\n" ); IntT N(opt.Int("n", INT_MAX, "Max no. of frames read")); IntT start(opt.Int("s", 0, " Start at nth frame")); IntT sub(opt.Int("sub", 1, "Only read in 1 in every n frames")); StringC fo(opt.String("of", "", "Output format.")); StringC fi(opt.String("if", "", "Input format.")); BooleanT verbose(opt. Boolean("v", false, "Verbose mode.")); BooleanT sync(opt. Boolean("sync", false, "The output frame numbers are synchronised with the input frame numbers")); FilenameC ip_name(opt.String("", "", "I/p file or file prefix")); FilenameC op_name(opt.String("", "", "O/p file")); opt.CompulsoryArgs (2); opt.Check (); VideoInC ip (ip_name, fi, verbose); if(!ip.IsOk()) { cerr << "Failed to open input file '" << ip_name << "'\n"; return 1; } if (start > 0) ip.Next(start-1); VideoOutC op(op_name, fo, verbose); if (sync) op.Next(start); if(!op.IsOk()) { cerr << "Failed to open output file '" << op_name << "'\n"; return 1; } while (ip.IsOk() && (N-- > 0)) { cerr << "Frame "<< ip.ImageNo() << '\n'; op.Put(ip.Data()); ip.Next(sub-1); if (sync) op.Next(sub-1); } return 0; }