2012-07-09 05:29:17 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <boost/program_options.hpp>
|
|
|
|
|
2012-07-12 08:42:38 +00:00
|
|
|
#include "encoder/video.hh"
|
|
|
|
#include "encoder/video_reader.hh"
|
|
|
|
#include "encoder/video_writer.hh"
|
|
|
|
|
2012-07-09 05:29:17 +00:00
|
|
|
int
|
|
|
|
main (int argc, char** argv)
|
|
|
|
{
|
|
|
|
namespace po = boost::program_options;
|
|
|
|
|
|
|
|
// Register all possible options
|
|
|
|
po::options_description desc("Allowed options");
|
|
|
|
desc.add_options()
|
|
|
|
("help,h", "produce help message")
|
|
|
|
("filter,f", po::value<std::vector<std::string> > (), "apply a filter")
|
|
|
|
("input-file,i", po::value<std::vector<std::string> > (), "file to treat")
|
2012-07-12 08:42:38 +00:00
|
|
|
("output,o", po::value<std::vector<std::string> > (), "output file")
|
|
|
|
("codec,c", po::value<std::vector<std::string> > (), "output codec")
|
2012-07-09 05:29:17 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
// Handle ./prpa file.avi instead of ./prpa --input-file=file.avi
|
|
|
|
po::positional_options_description p;
|
|
|
|
p.add("input-file", -1);
|
|
|
|
|
|
|
|
// Read command line
|
|
|
|
po::variables_map vm;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
po::store(po::command_line_parser(argc, argv).
|
|
|
|
options(desc).positional(p).run(), vm);
|
|
|
|
}
|
|
|
|
catch (po::invalid_command_line_syntax e)
|
|
|
|
{
|
|
|
|
std::cerr << argv[0] << ": " << e.what() << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
po::notify(vm);
|
|
|
|
|
|
|
|
// Handle -h and --help
|
|
|
|
if (argc <= 1 || vm.count("help"))
|
|
|
|
{
|
|
|
|
std::cout << desc << "\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// GO!
|
|
|
|
std::cout << "Given filters: ";
|
|
|
|
if (vm.count("filter"))
|
|
|
|
std::cout << vm["filter"].as<std::vector<std::string> > ().size()
|
|
|
|
<< std::endl;
|
|
|
|
else
|
|
|
|
std::cout << 0 << std::endl;
|
|
|
|
|
|
|
|
std::cout << "Given files: ";
|
|
|
|
if (vm.count("input-file"))
|
|
|
|
std::cout << vm["input-file"].as<std::vector<std::string> > ().size()
|
|
|
|
<< std::endl;
|
|
|
|
else
|
|
|
|
std::cout << 0 << std::endl;
|
|
|
|
|
2012-07-12 08:42:38 +00:00
|
|
|
VideoReader vr(vm["input-file"].as<std::vector<std::string> >()[0]);
|
|
|
|
VideoWriter vw = VideoWriter();
|
|
|
|
vw.open(vm["output"].as<std::vector<std::string> >()[0],
|
|
|
|
vm["codec"].as<std::vector<std::string> >()[0],
|
|
|
|
vr.fps_get(), vr.width_get(), vr.height_get());
|
|
|
|
vw.copy(vr);
|
|
|
|
vw.write();
|
|
|
|
|
2012-07-09 05:29:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|