#define little_endian_short(x) (x)
#endif
-bmp::bmp(const char *Filename)
+bmp::bmp(const char *Filename, const synfig::TargetParam& /* params */)
{
file=NULL;
filename=Filename;
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <cstdio>
/* === M A C R O S ========================================================= */
synfig::PixelFormat pf;
public:
- bmp(const char *filename);
+ bmp(const char *filename, const synfig::TargetParam& /* params */);
virtual ~bmp();
virtual bool set_rend_desc(synfig::RendDesc *desc);
/* === M E T H O D S ======================================================= */
-dv_trgt::dv_trgt(const char *Filename)
+dv_trgt::dv_trgt(const char *Filename,
+ const synfig::TargetParam& /* params */)
{
pid=-1;
file=NULL;
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <sys/types.h>
#include <cstdio>
unsigned char *buffer;
synfig::Color *color_buffer;
public:
- dv_trgt(const char *filename);
+ dv_trgt(const char *filename, const synfig::TargetParam& /* params */);
virtual ~dv_trgt();
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
** Copyright (c) 2007 Chris Moore
+** Copyright (c) 2010 Diego Barrios Romero
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
/* === M E T H O D S ======================================================= */
-ffmpeg_trgt::ffmpeg_trgt(const char *Filename)
+ffmpeg_trgt::ffmpeg_trgt(const char *Filename,
+ const synfig::TargetParam& params)
{
pid=-1;
file=NULL;
buffer=NULL;
color_buffer=0;
set_remove_alpha();
+ video_codec = params.video_codec;
+ bitrate = params.bitrate;
}
ffmpeg_trgt::~ffmpeg_trgt()
string command;
if( filename.c_str()[0] == '-' )
- command=strprintf("ffmpeg -f image2pipe -vcodec ppm -an -r %f -i pipe: -loop -hq -title \"%s\" -vcodec mpeg1video -y -- \"%s\"\n",desc.get_frame_rate(),get_canvas()->get_name().c_str(),filename.c_str());
+ command = strprintf("ffmpeg -f image2pipe -vcodec ppm -an"
+ " -r %f -i pipe: -loop -hq"
+ " -title \"%s\" -vcodec %s -b %i"
+ " -y -- \"%s\"\n",
+ desc.get_frame_rate(),
+ get_canvas()->get_name().c_str(),
+ video_codec.c_str(), bitrate,
+ filename.c_str());
else
- command=strprintf("ffmpeg -f image2pipe -vcodec ppm -an -r %f -i pipe: -loop -hq -title \"%s\" -vcodec mpeg1video -y \"%s\"\n",desc.get_frame_rate(),get_canvas()->get_name().c_str(),filename.c_str());
+ command = strprintf("ffmpeg -f image2pipe -vcodec ppm -an"
+ " -r %f -i pipe: -loop -hq"
+ " -title \"%s\" -vcodec %s -b %i"
+ " -y -- \"%s\"\n",
+ desc.get_frame_rate(),
+ get_canvas()->get_name().c_str(),
+ video_codec.c_str(), bitrate,
+ filename.c_str());
file=popen(command.c_str(),POPEN_BINARY_WRITE_TYPE);
// Close the unneeded pipeout
close(p[0]);
if( filename.c_str()[0] == '-' )
- execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec", "ppm", "-an", "-r", strprintf("%f", desc.get_frame_rate()).c_str(), "-i", "pipe:", "-loop", "-hq", "-title", get_canvas()->get_name().c_str(), "-vcodec", "mpeg1video", "-y", "--", filename.c_str(), (const char *)NULL);
+ execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec",
+ "ppm", "-an", "-r",
+ strprintf("%f", desc.get_frame_rate()).c_str(),
+ "-i", "pipe:", "-loop", "-hq",
+ "-title", get_canvas()->get_name().c_str(),
+ "-vcodec", video_codec.c_str(),
+ "-b", bitrate,
+ "-y", "--", filename.c_str(), (const char *)NULL);
else
- execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec", "ppm", "-an", "-r", strprintf("%f", desc.get_frame_rate()).c_str(), "-i", "pipe:", "-loop", "-hq", "-title", get_canvas()->get_name().c_str(), "-vcodec", "mpeg1video", "-y", filename.c_str(), (const char *)NULL);
+ execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec",
+ "ppm", "-an", "-r",
+ strprintf("%f", desc.get_frame_rate()).c_str(),
+ "-i", "pipe:", "-loop", "-hq",
+ "-title", get_canvas()->get_name().c_str(),
+ "-vcodec", video_codec.c_str(),
+ "-b", bitrate,
+ "-y", filename.c_str(), (const char *)NULL);
+
// We should never reach here unless the exec failed
synfig::error(_("Unable to open pipe to ffmpeg"));
return false;
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2010 Diego Barrios Romero
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <sys/types.h>
#include <cstdio>
/* === C L A S S E S & S T R U C T S ======================================= */
+class TargetParam;
+
class ffmpeg_trgt : public synfig::Target_Scanline
{
SYNFIG_TARGET_MODULE_EXT
synfig::String filename;
unsigned char *buffer;
synfig::Color *color_buffer;
+ std::string video_codec;
+ int bitrate;
public:
- ffmpeg_trgt(const char *filename);
+ ffmpeg_trgt(const char *filename,
+ const synfig::TargetParam& params);
virtual bool set_rend_desc(synfig::RendDesc *desc);
virtual bool init();
/* === M E T H O D S ======================================================= */
-gif::gif(const char *filename_):
+gif::gif(const char *filename_, const synfig::TargetParam& /* params */):
filename(filename_),
file( (filename=="-")?stdout:fopen(filename_,POPEN_BINARY_WRITE_TYPE) ),
imagecount(0),
#include <cstdio>
#include <synfig/surface.h>
#include <synfig/palette.h>
+#include <synfig/targetparam.h>
/* === M A C R O S ========================================================= */
void output_curr_palette();
public:
- gif(const char *filename);
+ gif(const char *filename, const synfig::TargetParam& /* params */);
virtual bool set_rend_desc(synfig::RendDesc *desc);
virtual bool init();
/* === M E T H O D S ======================================================= */
-imagemagick_trgt::imagemagick_trgt(const char *Filename)
+imagemagick_trgt::imagemagick_trgt(const char *Filename,
+ const synfig::TargetParam& /* params */)
{
pid=-1;
file=NULL;
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <sys/types.h>
#include <cstdio>
synfig::Color *color_buffer;
synfig::PixelFormat pf;
public:
- imagemagick_trgt(const char *filename);
+ imagemagick_trgt(const char *filename,
+ const synfig::TargetParam& /* params */);
virtual ~imagemagick_trgt();
virtual bool set_rend_desc(synfig::RendDesc *desc);
/* === M E T H O D S ======================================================= */
-jpeg_trgt::jpeg_trgt(const char *Filename)
+jpeg_trgt::jpeg_trgt(const char *Filename,
+ const synfig::TargetParam& /* params */)
{
file=NULL;
filename=Filename;
#define NOMINMAX
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <cstdio>
_ETL_BEGIN_CDECLS
#include <jpeglib.h>
unsigned char *buffer;
synfig::Color *color_buffer;
public:
- jpeg_trgt(const char *filename);
+ jpeg_trgt(const char *filename, const synfig::TargetParam& /* params */);
virtual ~jpeg_trgt();
virtual bool set_rend_desc(synfig::RendDesc *desc);
/* === M E T H O D S ======================================================= */
-Target_LibAVCodec::Target_LibAVCodec(const char *Filename):
+Target_LibAVCodec::Target_LibAVCodec(const char *Filename,
+ const synfig::TargetParam& /* params */):
filename(Filename)
{
if(!registered)
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <cstdio>
#include "synfig/surface.h"
synfig::Surface surface;
public:
- Target_LibAVCodec(const char *filename);
+ Target_LibAVCodec(const char *filename,
+ const synfig::TargetParam& /* params */);
virtual ~Target_LibAVCodec();
virtual bool init();
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <cstdio>
#include <vector>
public:
- magickpp_trgt(const char *filename) : filename(filename) { }
+ magickpp_trgt(const char *filename,
+ const synfig::TargetParam& /* params */) :
+ filename(filename) { }
virtual ~magickpp_trgt();
virtual bool set_rend_desc(synfig::RendDesc *desc);
return MNG_TRUE;
}
-mng_trgt::mng_trgt(const char *Filename) : filename(Filename)
+mng_trgt::mng_trgt(const char *Filename,
+ const synfig::TargetParam& /* params */) :
+ filename(Filename)
{
file=NULL;
buffer=NULL;
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <cstdio>
// #include <png.h>
public:
- mng_trgt(const char *filename);
+ mng_trgt(const char *filename, const synfig::TargetParam& /* params */);
virtual ~mng_trgt();
virtual bool set_rend_desc(synfig::RendDesc *desc);
return (bool)exr_file;
}
-exr_trgt::exr_trgt(const char *Filename):
+exr_trgt::exr_trgt(const char *Filename,
+ const synfig::TargetParam& /* params */):
multi_image(false),
imagecount(0),
filename(Filename),
#include <synfig/target_scanline.h>
#include <synfig/string.h>
#include <synfig/surface.h>
+#include <synfig/targetparam.h>
#include <cstdio>
#include <OpenEXR/ImfArray.h>
#include <OpenEXR/ImfRgbaFile.h>
bool ready();
public:
- exr_trgt(const char *filename);
+ exr_trgt(const char *filename, const synfig::TargetParam& /* params */);
virtual ~exr_trgt();
virtual bool set_rend_desc(synfig::RendDesc *desc);
//Target *png_trgt::New(const char *filename){ return new png_trgt(filename);}
-png_trgt::png_trgt(const char *Filename)
+png_trgt::png_trgt(const char *Filename,
+ const synfig::TargetParam& /* params */)
{
file=NULL;
filename=Filename;
#include <synfig/target_scanline.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <cstdio>
#include <png.h>
unsigned char *buffer;
synfig::Color *color_buffer;
public:
- png_trgt(const char *filename);
+ png_trgt(const char *filename, const synfig::TargetParam& /* params */);
virtual ~png_trgt();
virtual bool set_rend_desc(synfig::RendDesc *desc);
return new bsd_mpeg1(filename);
}
-bsd_mpeg1::bsd_mpeg1(const char *Filename)
+bsd_mpeg1::bsd_mpeg1(const char *Filename,
+ const synfig::TargetParam& /* params */)
{
filename=Filename;
passthru=ppm::New((tmp_dir+"temp.ppm").c_str());
String filename;
FILE *paramfile;
public:
- bsd_mpeg1(const char *filename);
+ bsd_mpeg1(const char *filename, const synfig::TargetParam& /* params */);
virtual bool set_rend_desc(synfig::RendDesc *desc);
virtual bool start_frame(synfig::ProgressCallback *cb);
/* === M E T H O D S ======================================================= */
-ppm::ppm(const char *Filename)
+ppm::ppm(const char *Filename, const synfig::TargetParam& /* params */)
{
filename=Filename;
multi_image=false;
#include <synfig/target_scanline.h>
#include <synfig/string.h>
#include <synfig/smartfile.h>
+#include <synfig/targetparam.h>
#include <cstdio>
/* === M A C R O S ========================================================= */
synfig::Color *color_buffer;
unsigned char *buffer;
public:
- ppm(const char *filename);
+ ppm(const char *filename, const synfig::TargetParam& /* params */);
virtual ~ppm();
virtual bool set_rend_desc(synfig::RendDesc *desc);
/* === M E T H O D S ======================================================= */
-yuv::yuv(const char *FILENAME):
+yuv::yuv(const char *FILENAME, const synfig::TargetParam& /* params */):
filename(FILENAME),
file( (filename=="-")?stdout:fopen(filename.c_str(),POPEN_BINARY_WRITE_TYPE) ),
dithering(true)
#include <synfig/string.h>
#include <synfig/surface.h>
#include <synfig/smartfile.h>
+#include <synfig/targetparam.h>
#include <cstdio>
/* === M A C R O S ========================================================= */
public:
- yuv(const char *filename);
+ yuv(const char *filename, const synfig::TargetParam& /* params */);
virtual ~yuv();
virtual bool init();
//! Marks the start of the targets in the module's inventory
#define BEGIN_TARGETS {
-#define TARGET(x) \
- synfig::Target::book()[synfig::String(x::name__)].factory = \
- reinterpret_cast<synfig::Target::Factory> (x::create); \
- synfig::Target::book()[synfig::String(x::name__)].filename = \
- synfig::String(x::ext__); \
+#define TARGET(x) \
+ synfig::Target::book()[synfig::String(x::name__)].factory = \
+ reinterpret_cast<synfig::Target::Factory> (x::create); \
+ synfig::Target::book()[synfig::String(x::name__)].filename = \
+ synfig::String(x::ext__); \
+ synfig::Target::book()[synfig::String(x::name__)].target_param = \
+ synfig::TargetParam(); \
synfig::Target::ext_book()[synfig::String(x::ext__)]=x::name__;
#define TARGET_EXT(x,y) synfig::Target::ext_book()[synfig::String(y)]=x::name__;
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2010 Diego Barrios Romero
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
#include "canvas.h"
#include "target_null.h"
#include "target_null_tile.h"
+#include "targetparam.h"
using namespace synfig;
using namespace etl;
// At least one target must be available.
book()["null"].factory =
reinterpret_cast<synfig::Target::Factory>(&Target_Null::create);
- book()["null"].filename = "null";
+ book()["null"].filename = "null";
+ book()["null"].target_param = TargetParam();
ext_book()["null"]="null";
book()["null-tile"].factory =
- reinterpret_cast<synfig::Target::Factory>(&Target_Null_Tile::create);
- book()["null-tile"].filename = "null-tile";
+ reinterpret_cast<synfig::Target::Factory>(&Target_Null_Tile::create);
+ book()["null-tile"].filename = "null-tile";
+ book()["null-tile"].target_param = TargetParam();
ext_book()["null-tile"]="null-tile";
return true;
Target::Handle
-Target::create(const String &name, const String &filename)
+Target::create(const String &name, const String &filename,
+ synfig::TargetParam params)
{
if(!book().count(name))
return handle<Target>();
- return Target::Handle(book()[name].factory(filename.c_str()));
+ return Target::Handle(book()[name].factory(filename.c_str(), params));
}
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
** Copyright (c) 2007 Chris Moore
+** Copyright (c) 2010 Diego Barrios Romero
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
//#include "general.h"
#include "color.h"
#include "canvas.h"
+#include "targetparam.h"
/* === M A C R O S ========================================================= */
//! \writeme
-#define SYNFIG_TARGET_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Target *create(const char *filename);
+#define SYNFIG_TARGET_MODULE_EXT public: static const char name__[], \
+ version__[], ext__[], cvs_id__[]; \
+ static Target* create (const char *filename, \
+ synfig::TargetParam p);
//! Sets the name of the target
#define SYNFIG_TARGET_SET_NAME(class,x) const char class::name__[]=x
#define SYNFIG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
//! \writeme
-#define SYNFIG_TARGET_INIT(class) synfig::Target* class::create(const char *filename) { return new class(filename); }
+#define SYNFIG_TARGET_INIT(class) \
+ synfig::Target* class::create (const char *filename, \
+ synfig::TargetParam p) \
+ { return new class(filename, p); }
/* === T Y P E D E F S ===================================================== */
class RendDesc;
class Canvas;
class ProgressCallback;
+class TargetParam;
/*! \class Target
** \brief Render-target
/*! As a pointer to the constructor, it represents a "factory" of targets.
** Receives the output filename (including path).
*/
- typedef Target* (*Factory)(const char *filename);
-
+ typedef Target* (*Factory)(const char *filename, TargetParam p);
+
struct BookEntry
{
Factory factory;
String filename; ///< Output filename including path
+ TargetParam target_param; ///< Target module parameters
};
//! Book of types of targets indexed by the name of the Target.
virtual bool init() { return true; }
//! Creates a new Target described by \a type, outputting to a file described by \a filename.
- static Handle create(const String &type, const String &filename);
+ static Handle create(const String &type, const String &filename,
+ synfig::TargetParam params);
}; // END of class Target
}; // END of namespace synfig
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file synfig/targetparam.h
+** \brief Class for extra parameters of the target modules
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2010 Diego Barrios Romero
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_TARGETPARAM_H
+#define __SYNFIG_TARGETPARAM_H
+
+#include <string>
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfig {
+
+struct TargetParam
+{
+ std::string video_codec;
+ int bitrate;
+};
+
+}; // END of namespace synfig
+
+/* === E N D =============================================================== */
+
+#endif
+
#include <synfig/layer.h>
#include <synfig/canvas.h>
#include <synfig/target.h>
+#include <synfig/targetparam.h>
#include <synfig/time.h>
#include <synfig/string.h>
#include <synfig/paramdesc.h>
flag=="-Q" || flag=="-s" || flag=="-t" || flag=="-T" || flag=="-w" ||
flag=="--append" || flag=="--begin-time" || flag=="--canvas-info"|| flag=="--dpi" || flag=="--dpi-x" ||
flag=="--dpi-y" || flag=="--end-time" || flag=="--fps" || flag=="--layer-info" || flag=="--start-time" ||
- flag=="--time" );
+ flag=="--time" || flag=="-vc" || flag=="-vb");
}
int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster)
return SYNFIGTOOL_OK;
}
+int extract_target_params(arg_list_t& arg_list,
+ TargetParam& params)
+{
+ arg_list_t::iterator iter;
+
+ for(iter=arg_list.begin(); iter!=arg_list.end(); iter++)
+ {
+ if(*iter=="-vc")
+ {
+ // Target video codec
+ params.video_codec = extract_parameter(arg_list, iter);
+ }
+ else if(*iter=="-vb")
+ {
+ // Target bitrate
+ params.bitrate =
+ atoi(extract_parameter(arg_list, iter).c_str());
+ }
+ else if (flag_requires_value(*iter))
+ iter++;
+ }
+
+ return SYNFIGTOOL_OK;
+}
+
int extract_append(arg_list_t &arg_list,string &filename)
{
arg_list_t::iterator iter;
}
}
+ TargetParam target_parameters;
+ // Extract the extra parameters for the targets that
+ // need them.
+ if (target_name == "ffmpeg")
+ extract_target_params(imageargs, target_parameters);
+
// If the target type is STILL not yet defined, then
// set it to a some sort of default
if(target_name.empty())
VERBOSE_OUT(4)<<"outfile_name="<<job_list.front().outfilename<<endl;
VERBOSE_OUT(4)<<_("Creating the target...")<<endl;
- job_list.front().target=synfig::Target::create(target_name,job_list.front().outfilename);
+ job_list.front().target =
+ synfig::Target::create(target_name,
+ job_list.front().outfilename,
+ target_parameters);
if(target_name=="sif")
job_list.front().sifout=true;