#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();
BEGIN_TARGETS
TARGET(ffmpeg_trgt)
TARGET_EXT(ffmpeg_trgt,"avi")
+ TARGET_EXT(ffmpeg_trgt,"flv")
+ TARGET_EXT(ffmpeg_trgt,"mkv")
TARGET_EXT(ffmpeg_trgt,"mpg")
- TARGET_EXT(ffmpeg_trgt,"rm")
- TARGET_EXT(ffmpeg_trgt,"asf")
- TARGET_EXT(ffmpeg_trgt,"swf")
- TARGET_EXT(ffmpeg_trgt,"yuv")
+ TARGET_EXT(ffmpeg_trgt,"ogv")
TARGET_EXT(ffmpeg_trgt,"rgb")
+ TARGET_EXT(ffmpeg_trgt,"wmv")
+ TARGET_EXT(ffmpeg_trgt,"yuv")
END_TARGETS
BEGIN_IMPORTERS
IMPORTER_EXT(ffmpeg_mptr,"avi")
** \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();
+
+ // Set default video codec and bitrate if they weren't given.
+ if (params.video_codec == "none")
+ video_codec = "mpeg1video";
+ else
+ video_codec = params.video_codec;
+
+ if (params.bitrate == -1)
+ bitrate = 200;
+ else
+ 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_input"
+ " -metadata title=\"%s\" "
+ " -vcodec %s -b %ik"
+ " -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_input"
+ " -metadata title=\"%s\" "
+ "-vcodec %s -b %ik"
+ " -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);
+ {
+ // x264 codec needs -vpre hq parameters
+ if (video_codec == "libx264")
+ execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec",
+ "ppm", "-an", "-r",
+ strprintf("%f", desc.get_frame_rate()).c_str(),
+ "-i", "pipe:", "-loop_input", "-metadata",
+ strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+ "-vcodec", video_codec.c_str(),
+ "-b", strprintf("%ik", bitrate).c_str(),
+ "-vpre", "hq",
+ "-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_input", "-metadata",
+ strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+ "-vcodec", video_codec.c_str(),
+ "-b", strprintf("%ik", bitrate).c_str(),
+ "-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);
+ {
+ if (video_codec == "libx264")
+ execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec",
+ "ppm", "-an", "-r",
+ strprintf("%f", desc.get_frame_rate()).c_str(),
+ "-i", "pipe:", "-loop_input",
+ "-metadata",
+ strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+ "-vcodec", video_codec.c_str(),
+ "-b", strprintf("%ik", bitrate).c_str(),
+ "-vpre", "hq",
+ "-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_input",
+ "-metadata",
+ strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+ "-vcodec", video_codec.c_str(),
+ "-b", strprintf("%ik", bitrate).c_str(),
+ "-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();
target_null.h \
target_null_tile.h \
target_scanline.h \
- target_tile.h
+ target_tile.h \
+ targetparam.h
TARGETSOURCES = \
target_multi.cpp \
//! 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
+{
+ //! Default constructor
+ /*! Not valid default values, if they are not modified before
+ * passing them to the target module, it would override them with
+ * its own valid default settings.
+ */
+ TargetParam (): video_codec("none"), bitrate(-1) { }
+
+ TargetParam (const std::string& Video_codec, int Bitrate):
+ video_codec(Video_codec), bitrate(Bitrate)
+ { }
+
+ std::string video_codec;
+ int bitrate;
+};
+
+}; // END of namespace synfig
+
+/* === E N D =============================================================== */
+
+#endif
+
bin_PROGRAMS = \
synfig
-
synfig_SOURCES = \
+ definitions.h \
+ progress.h \
+ renderprogress.h \
+ job.h \
main.cpp
synfig_LDADD = \
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file tool/definitions.h
+** \brief Definitions for synfig tool
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007, 2008 Chris Moore
+**
+** 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
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_DEFINITIONS_H
+#define __SYNFIG_DEFINITIONS_H
+
+/* === M A C R O S ========================================================= */
+
+#ifdef ENABLE_NLS
+#undef _
+#define _(x) gettext(x)
+#else
+#undef _
+#define _(x) (x)
+#endif
+
+enum exit_code
+{
+ SYNFIGTOOL_OK = 0,
+ SYNFIGTOOL_FILENOTFOUND = 1,
+ SYNFIGTOOL_BORED = 2,
+ SYNFIGTOOL_HELP = 3,
+ SYNFIGTOOL_UNKNOWNARGUMENT = 4,
+ SYNFIGTOOL_UNKNOWNERROR = 5,
+ SYNFIGTOOL_INVALIDTARGET = 6,
+ SYNFIGTOOL_RENDERFAILURE = 7,
+ SYNFIGTOOL_BLANK = 8,
+ SYNFIGTOOL_BADVERSION = 9,
+ SYNFIGTOOL_MISSINGARGUMENT =10
+};
+
+#ifndef VERSION
+#define VERSION "unknown"
+#define PACKAGE "synfig-tool"
+#endif
+
+#ifdef DEFAULT_QUALITY
+#undef DEFAULT_QUALITY
+#endif
+
+#define DEFAULT_QUALITY 2
+#define VERBOSE_OUT(x) if(verbosity>=(x))std::cerr
+
+/* === G L O B A L S ======================================================= */
+
+extern const char *progname;
+extern int verbosity;
+extern bool be_quiet;
+extern bool print_benchmarks;
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file tool/job.h
+** \brief Job class
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007, 2008 Chris Moore
+**
+** 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
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_JOB_H
+#define __SYNFIG_JOB_H
+
+using namespace synfig;
+
+#include <synfig/string.h>
+#include <synfig/canvas.h>
+#include <synfig/target.h>
+#include "definitions.h"
+
+struct Job
+{
+ String filename;
+ String outfilename;
+
+ RendDesc desc;
+
+ Canvas::Handle root;
+ Canvas::Handle canvas;
+ Target::Handle target;
+
+ int quality;
+ bool sifout;
+ bool list_canvases;
+
+ bool canvas_info, canvas_info_all, canvas_info_time_start, canvas_info_time_end, canvas_info_frame_rate,
+ canvas_info_frame_start, canvas_info_frame_end, canvas_info_w, canvas_info_h, canvas_info_image_aspect,
+ canvas_info_pw, canvas_info_ph, canvas_info_pixel_aspect, canvas_info_tl, canvas_info_br,
+ canvas_info_physical_w, canvas_info_physical_h, canvas_info_x_res, canvas_info_y_res, canvas_info_span,
+ canvas_info_interlaced, canvas_info_antialias, canvas_info_clamp, canvas_info_flags, canvas_info_focus,
+ canvas_info_bg_color, canvas_info_metadata;
+
+ Job()
+ {
+ canvas_info = canvas_info_all = canvas_info_time_start = canvas_info_time_end = canvas_info_frame_rate = canvas_info_frame_start = canvas_info_frame_end = canvas_info_w = canvas_info_h = canvas_info_image_aspect = canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect = canvas_info_tl = canvas_info_br = canvas_info_physical_w = canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res = canvas_info_span = canvas_info_interlaced = canvas_info_antialias = canvas_info_clamp = canvas_info_flags = canvas_info_focus = canvas_info_bg_color = canvas_info_metadata = false;
+ };
+};
+
+#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>
#include <synfig/main.h>
#include <synfig/guid.h>
#include <autorevision.h>
+#include "definitions.h"
+#include "progress.h"
+#include "renderprogress.h"
+#include "job.h"
#endif
using namespace std;
using namespace etl;
using namespace synfig;
-/* === M A C R O S ========================================================= */
-
-#ifdef ENABLE_NLS
-#undef _
-#define _(x) gettext(x)
-#else
-#undef _
-#define _(x) (x)
-#endif
-
-enum exit_code
-{
- SYNFIGTOOL_OK = 0,
- SYNFIGTOOL_FILENOTFOUND = 1,
- SYNFIGTOOL_BORED = 2,
- SYNFIGTOOL_HELP = 3,
- SYNFIGTOOL_UNKNOWNARGUMENT = 4,
- SYNFIGTOOL_UNKNOWNERROR = 5,
- SYNFIGTOOL_INVALIDTARGET = 6,
- SYNFIGTOOL_RENDERFAILURE = 7,
- SYNFIGTOOL_BLANK = 8,
- SYNFIGTOOL_BADVERSION = 9,
- SYNFIGTOOL_MISSINGARGUMENT =10
-};
-
-#ifndef VERSION
-#define VERSION "unknown"
-#define PACKAGE "synfig-tool"
-#endif
-
-#ifdef DEFAULT_QUALITY
-#undef DEFAULT_QUALITY
-#endif
-
-#define DEFAULT_QUALITY 2
-#define VERBOSE_OUT(x) if(verbosity>=(x))std::cerr
-
/* === G L O B A L S ======================================================= */
const char *progname;
bool be_quiet=false;
bool print_benchmarks=false;
-/* === M E T H O D S ======================================================= */
-
-class Progress : public synfig::ProgressCallback
+//! Allowed video codecs
+/*! \warning This variable is linked to allowed_video_codecs_description,
+ * if you change this you must change the other acordingly.
+ * \warning These codecs are linked to the filename extensions for
+ * mod_ffmpeg. If you change this you must change the others acordingly.
+ */
+const char* allowed_video_codecs[] =
{
- const char *program;
-
-public:
-
- Progress(const char *name):program(name) { }
-
- virtual bool
- task(const String &task)
- {
- VERBOSE_OUT(1)<<program<<": "<<task<<std::endl;
- return true;
- }
-
- virtual bool
- error(const String &task)
- {
- std::cerr<<program<<": "<<_("error")<<": "<<task<<std::endl;
- return true;
- }
-
- virtual bool
- warning(const String &task)
- {
- std::cerr<<program<<": "<<_("warning")<<": "<<task<<std::endl;
- return true;
- }
-
- virtual bool
- amount_complete(int /*current*/, int /*total*/)
- {
- return true;
- }
+ "flv", "h263p", "huffyuv", "libtheora", "libx264", "libxvid",
+ "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
+ "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", NULL
};
-class RenderProgress : public synfig::ProgressCallback
+//! Allowed video codecs description.
+/*! \warning This variable is linked to allowed_video_codecs,
+ * if you change this you must change the other acordingly.
+ */
+const char* allowed_video_codecs_description[] =
{
- string taskname;
-
- etl::clock clk;
- int clk_scanline; // The scanline at which the clock was reset
- etl::clock clk2;
-
- float last_time;
-public:
-
- RenderProgress():clk_scanline(0), last_time(0) { }
-
- virtual bool
- task(const String &thetask)
- {
- taskname=thetask;
- return true;
- }
-
- virtual bool
- error(const String &task)
- {
- std::cout<<_("error")<<": "<<task<<std::endl;
- return true;
- }
-
- virtual bool
- warning(const String &task)
- {
- std::cout<<_("warning")<<": "<<task<<std::endl;
- return true;
- }
-
- virtual bool
- amount_complete(int scanline, int h)
- {
- if(be_quiet)return true;
- if(scanline!=h)
- {
- const float time(clk()*(float)(h-scanline)/(float)(scanline-clk_scanline));
- const float delta(time-last_time);
-
- int weeks=0,days=0,hours=0,minutes=0,seconds=0;
-
- last_time=time;
-
- if(clk2()<0.2)
- return true;
- clk2.reset();
-
- if(scanline)
- seconds=(int)time+1;
- else
- {
- //cerr<<"reset"<<endl;
- clk.reset();
- clk_scanline=scanline;
- }
-
- if(seconds<0)
- {
- clk.reset();
- clk_scanline=scanline;
- seconds=0;
- }
- while(seconds>=60)
- minutes++,seconds-=60;
- while(minutes>=60)
- hours++,minutes-=60;
- while(hours>=24)
- days++,hours-=24;
- while(days>=7)
- weeks++,days-=7;
-
- cerr<<taskname<<": "<<_("Line")<<" "<<scanline<<_(" of ")<<h<<" -- ";
- //cerr<<time/(h-clk_scanline)<<" ";
- /*
- if(delta>=-time/(h-clk_scanline) )
- cerr<<">";
- */
- if(delta>=0 && clk()>4.0 && scanline>clk_scanline+200)
- {
- //cerr<<"reset"<<endl;
- clk.reset();
- clk_scanline=scanline;
- }
-
- if(weeks)
- cerr<<weeks<<"w ";
- if(days)
- cerr<<days<<"d ";
- if(hours)
- cerr<<hours<<"h ";
- if(minutes)
- cerr<<minutes<<"m ";
- if(seconds)
- cerr<<seconds<<"s ";
-
- cerr<<" \r";
- }
- else
- cerr<<taskname<<": "<<_("DONE")<<" "<<endl;;
- return true;
- }
+ "Flash Video (FLV) / Sorenson Spark / Sorenson H.263.",
+ "H.263+ / H.263-1998 / H.263 version 2.",
+ "Huffyuv / HuffYUV.",
+ "libtheora Theora.",
+ "libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10.",
+ "libxvidcore MPEG-4 part 2.",
+ "MJPEG (Motion JPEG).",
+ "raw MPEG-1 video.",
+ "raw MPEG-2 video.",
+ "MPEG-4 part 2.",
+ "MPEG-4 part 2 Microsoft variant version 3.",
+ "MPEG-4 part 2 Microsoft variant version 1.",
+ "MPEG-4 part 2 Microsoft variant version 2.",
+ "Windows Media Video 7.",
+ "Windows Media Video 8.",
+ NULL
};
-struct Job
-{
- String filename;
- String outfilename;
-
- RendDesc desc;
-
- Canvas::Handle root;
- Canvas::Handle canvas;
- Target::Handle target;
-
- int quality;
- bool sifout;
- bool list_canvases;
-
- bool canvas_info, canvas_info_all, canvas_info_time_start, canvas_info_time_end, canvas_info_frame_rate,
- canvas_info_frame_start, canvas_info_frame_end, canvas_info_w, canvas_info_h, canvas_info_image_aspect,
- canvas_info_pw, canvas_info_ph, canvas_info_pixel_aspect, canvas_info_tl, canvas_info_br,
- canvas_info_physical_w, canvas_info_physical_h, canvas_info_x_res, canvas_info_y_res, canvas_info_span,
- canvas_info_interlaced, canvas_info_antialias, canvas_info_clamp, canvas_info_flags, canvas_info_focus,
- canvas_info_bg_color, canvas_info_metadata;
-
- Job()
- {
- canvas_info = canvas_info_all = canvas_info_time_start = canvas_info_time_end = canvas_info_frame_rate = canvas_info_frame_start = canvas_info_frame_end = canvas_info_w = canvas_info_h = canvas_info_image_aspect = canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect = canvas_info_tl = canvas_info_br = canvas_info_physical_w = canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res = canvas_info_span = canvas_info_interlaced = canvas_info_antialias = canvas_info_clamp = canvas_info_flags = canvas_info_focus = canvas_info_bg_color = canvas_info_metadata = false;
- };
-};
+/* === T Y P E D E F S ===================================================== */
typedef list<String> arg_list_t;
typedef list<Job> job_list_t;
+/* === M E T H O D S ======================================================= */
+
void guid_test()
{
cout<<"GUID Test"<<endl;
display_help_option("--layer-info", "<layer>", _("Print out layer's description, parameter info, etc."));
display_help_option("--layers", NULL, _("Print out the list of available layers"));
display_help_option("--targets", NULL, _("Print out the list of available targets"));
+ display_help_option("--target-video-codecs", NULL, _("Print out the list of available target video codecs"));
display_help_option("--importers", NULL, _("Print out the list of available importers"));
display_help_option("--valuenodes", NULL, _("Print out the list of available ValueNodes"));
display_help_option("--modules", NULL, _("Print out the list of loaded modules"));
cerr << endl;
}
+void display_target_video_codecs_help ()
+{
+ for (int i = 0; allowed_video_codecs[i] != NULL &&
+ allowed_video_codecs_description[i] != NULL; i++)
+ cout << " " << allowed_video_codecs[i] << ": \t"
+ << allowed_video_codecs_description[i]
+ << endl;
+}
+
int process_global_flags(arg_list_t &arg_list)
{
arg_list_t::iterator iter, next;
return SYNFIGTOOL_HELP;
}
+ if(*iter == "--target-video-codecs")
+ {
+ display_target_video_codecs_help();
+
+ return SYNFIGTOOL_HELP;
+ }
+
if(*iter == "--valuenodes")
{
Progress p(PACKAGE);
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;
}
+/*! Extract a parameter from the argument list
+ *
+ * \param arg_list Argument list from wich the parameter is extracted.
+ * \param iter Iterator pointing to the argument list parameter to be
+ * extracted.
+ * \param next Iterator pointing to the next argument.
+ */
+string extract_parameter (arg_list_t& arg_list,
+ arg_list_t::iterator& iter,
+ arg_list_t::iterator& next)
+{
+ string parameter;
+ arg_list.erase(iter);
+ iter = next++;
+ parameter = *iter;
+ arg_list.erase(iter);
+ return parameter;
+}
+
int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
{
arg_list_t::iterator iter, next;
{
if(*iter=="-w")
{
- arg_list.erase(iter);
- iter=next++;
- w=atoi(iter->c_str());
- arg_list.erase(iter);
+ w = atoi(extract_parameter(arg_list, iter, next).c_str());
}
else if(*iter=="-h")
{
- arg_list.erase(iter);
- iter=next++;
- h=atoi(iter->c_str());
- arg_list.erase(iter);
+ h = atoi(extract_parameter(arg_list, iter, next).c_str());
}
else if(*iter=="-a")
{
int a;
- arg_list.erase(iter);
- iter=next++;
- a=atoi(iter->c_str());
+ a = atoi(extract_parameter(arg_list, iter, next).c_str());
desc.set_antialias(a);
VERBOSE_OUT(1)<<strprintf(_("Antialiasing set to %d, (%d samples per pixel)"),a,a*a)<<endl;
- arg_list.erase(iter);
}
else if(*iter=="-s")
{
- arg_list.erase(iter);
- iter=next++;
- span=atof(iter->c_str());
+ span = atoi(extract_parameter(arg_list, iter, next).c_str());
VERBOSE_OUT(1)<<strprintf(_("Span set to %d units"),span)<<endl;
- arg_list.erase(iter);
}
else if(*iter=="--fps")
{
- arg_list.erase(iter);
- iter=next++;
- float fps=atof(iter->c_str());
+ float fps = atof(extract_parameter(arg_list, iter, next).c_str());
desc.set_frame_rate(fps);
- arg_list.erase(iter);
VERBOSE_OUT(1)<<strprintf(_("Frame rate set to %d frames per second"),fps)<<endl;
}
else if(*iter=="--dpi")
{
- arg_list.erase(iter);
- iter=next++;
- float dpi=atof(iter->c_str());
+ float dpi = atof(extract_parameter(arg_list, iter, next).c_str());
float dots_per_meter=dpi*39.3700787402;
desc.set_x_res(dots_per_meter).set_y_res(dots_per_meter);
- arg_list.erase(iter);
VERBOSE_OUT(1)<<strprintf(_("Physical resolution set to %f dpi"),dpi)<<endl;
}
else if(*iter=="--dpi-x")
{
- arg_list.erase(iter);
- iter=next++;
- float dpi=atof(iter->c_str());
+ float dpi = atof(extract_parameter(arg_list, iter, next).c_str());
float dots_per_meter=dpi*39.3700787402;
desc.set_x_res(dots_per_meter);
- arg_list.erase(iter);
VERBOSE_OUT(1)<<strprintf(_("Physical X resolution set to %f dpi"),dpi)<<endl;
}
else if(*iter=="--dpi-y")
{
- arg_list.erase(iter);
- iter=next++;
- float dpi=atof(iter->c_str());
+ float dpi = atof(extract_parameter(arg_list, iter, next).c_str());
float dots_per_meter=dpi*39.3700787402;
desc.set_y_res(dots_per_meter);
- arg_list.erase(iter);
VERBOSE_OUT(1)<<strprintf(_("Physical Y resolution set to %f dpi"),dpi)<<endl;
}
else if(*iter=="--start-time" || *iter=="--begin-time")
{
- arg_list.erase(iter);
- iter=next++;
- desc.set_time_start(Time(*iter,desc.get_frame_rate()));
- arg_list.erase(iter);
+ desc.set_time_start(Time(extract_parameter(arg_list, iter, next),
+ desc.get_frame_rate()));
}
else if(*iter=="--end-time")
{
- arg_list.erase(iter);
- iter=next++;
- desc.set_time_end(Time(*iter,desc.get_frame_rate()));
- arg_list.erase(iter);
+ desc.set_time_end(Time(extract_parameter(arg_list, iter, next),
+ desc.get_frame_rate()));
}
else if(*iter=="--time")
{
- arg_list.erase(iter);
- iter=next++;
- desc.set_time(Time(*iter,desc.get_frame_rate()));
+ desc.set_time(Time(extract_parameter(arg_list, iter, next),
+ desc.get_frame_rate()));
VERBOSE_OUT(1)<<_("Rendering frame at ")<<desc.get_time_start().get_string(desc.get_frame_rate())<<endl;
- arg_list.erase(iter);
}
else if(*iter=="-g")
{
synfig::warning("Gamma argument is currently ignored");
- arg_list.erase(iter);
- iter=next++;
- //desc.set_gamma(Gamma(atof(iter->c_str())));
- arg_list.erase(iter);
+ //desc.set_gamma(Gamma(atoi(extract_parameter(arg_list, iter, next).c_str())));
}
else if (flag_requires_value(*iter))
- iter=next++;
+ iter++;
}
if (w||h)
{
{
if(*iter=="-Q")
{
- arg_list.erase(iter);
- iter=next++;
- quality=atoi(iter->c_str());
+ quality = atoi(extract_parameter(arg_list, iter, next).c_str());
VERBOSE_OUT(1)<<strprintf(_("Quality set to %d"),quality)<<endl;
- arg_list.erase(iter);
}
else if (flag_requires_value(*iter))
- iter=next++;
+ iter++;
}
return SYNFIGTOOL_OK;
{
if(*iter=="-T")
{
- arg_list.erase(iter);
- iter=next++;
- threads=atoi(iter->c_str());
+ threads = atoi(extract_parameter(arg_list, iter, next).c_str());
VERBOSE_OUT(1)<<strprintf(_("Threads set to %d"),threads)<<endl;
- arg_list.erase(iter);
}
else if (flag_requires_value(*iter))
- iter=next++;
+ iter++;
}
return SYNFIGTOOL_OK;
{
if(*iter=="-t")
{
- arg_list.erase(iter);
- iter=next++;
- type=*iter;
- arg_list.erase(iter);
+ type = extract_parameter(arg_list, iter, next);
+ VERBOSE_OUT(1)<<strprintf(_("Target set to %s"), type.c_str())<<endl;
}
else if (flag_requires_value(*iter))
- iter=next++;
+ iter++;
}
return SYNFIGTOOL_OK;
}
+int extract_target_params(arg_list_t& arg_list,
+ TargetParam& params)
+{
+ int ret;
+ ret = SYNFIGTOOL_OK;
+ // If -vc parameter is provided, -vb parameter is needed.
+ bool need_bitrate_parameter = false;
+ arg_list_t::iterator iter, next;
+
+ for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++)
+ {
+ if(*iter=="-vc")
+ {
+ // Target video codec
+ params.video_codec = extract_parameter(arg_list, iter, next);
+
+ // video_codec string to lowercase
+ transform (params.video_codec.begin(),
+ params.video_codec.end(),
+ params.video_codec.begin(),
+ ::tolower);
+
+ int local_ret;
+ local_ret = SYNFIGTOOL_UNKNOWNARGUMENT;
+
+ // Check if the given video codec is allowed.
+ for (int i = 0; local_ret != SYNFIGTOOL_OK &&
+ allowed_video_codecs[i] != NULL; i++)
+ if (params.video_codec == allowed_video_codecs[i])
+ local_ret = SYNFIGTOOL_OK;
+
+ ret = local_ret;
+
+ if (ret == SYNFIGTOOL_OK)
+ {
+ VERBOSE_OUT(1)<<strprintf(_("Target video codec set to %s"), params.video_codec.c_str())<<endl;
+ need_bitrate_parameter = true;
+ }
+ }
+ else if(*iter=="-vb")
+ {
+ need_bitrate_parameter = false;
+ // Target bitrate
+ params.bitrate =
+ atoi(extract_parameter(arg_list, iter, next).c_str());
+ VERBOSE_OUT(1)<<strprintf(_("Target bitrate set to %dk"),params.bitrate)<<endl;
+ }
+ else if (flag_requires_value(*iter))
+ iter++;
+ }
+
+ if (need_bitrate_parameter)
+ ret = SYNFIGTOOL_MISSINGARGUMENT;
+
+ return ret;
+}
+
int extract_append(arg_list_t &arg_list,string &filename)
{
arg_list_t::iterator iter, next;
{
if(*iter=="--append")
{
- arg_list.erase(iter);
- iter=next++;
- filename=*iter;
- arg_list.erase(iter);
+ filename = extract_parameter(arg_list, iter, next);
}
else if (flag_requires_value(*iter))
- iter=next++;
+ iter++;
}
return SYNFIGTOOL_OK;
{
if(*iter=="-o")
{
- arg_list.erase(iter);
- iter=next++;
- outfile=*iter;
- arg_list.erase(iter);
+ outfile = extract_parameter(arg_list, iter, next);
ret=SYNFIGTOOL_OK;
}
else if (flag_requires_value(*iter))
- iter=next++;
+ iter++;
}
return ret;
{
if(*iter=="-c")
{
- arg_list.erase(iter);
- iter=next++;
- canvasid=*iter;
- arg_list.erase(iter);
+ canvasid = extract_parameter(arg_list, iter, next);
}
else if (flag_requires_value(*iter))
- iter=next++;
+ iter++;
}
return SYNFIGTOOL_OK;
{
arg_list_t::iterator iter, next;
- for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++)
+ for(next=arg_list.begin(), iter = next++; iter!=arg_list.end();
+ iter = next++)
if(*iter=="--list-canvases")
{
list_canvases = true;
if(*iter=="--canvas-info")
{
job.canvas_info = true;
- arg_list.erase(iter);
- iter=next++;
- String values(*iter), value;
- arg_list.erase(iter);
+ String values(extract_parameter(arg_list, iter, next)), value;
std::string::size_type pos;
while (!values.empty())
}
}
+ TargetParam target_parameters;
+ // Extract the extra parameters for the targets that
+ // need them.
+ if (target_name == "ffmpeg")
+ {
+ int status;
+ status = extract_target_params(imageargs, target_parameters);
+ if (status == SYNFIGTOOL_UNKNOWNARGUMENT)
+ {
+ cerr << strprintf(_("Unknown target video codec: %s."),
+ target_parameters.video_codec.c_str())
+ << endl;
+ cerr << _("Available target video codecs are:")
+ << endl;
+ display_target_video_codecs_help();
+
+ return SYNFIGTOOL_UNKNOWNARGUMENT;
+ }
+ else if (status == SYNFIGTOOL_MISSINGARGUMENT)
+ {
+ cerr << _("Missing argument: \"-vb\".") << endl;
+
+ return SYNFIGTOOL_MISSINGARGUMENT;
+ }
+ }
+
// 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;
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file tool/progress.h
+** \brief Progress class
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007, 2008 Chris Moore
+**
+** 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
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_PROGRESS_H
+#define __SYNFIG_PROGRESS_H
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+#include <synfig/string.h>
+#include "definitions.h"
+
+class Progress : public synfig::ProgressCallback
+{
+ const char *program;
+
+public:
+
+ Progress(const char *name):program(name) { }
+
+ virtual bool
+ task(const String &task)
+ {
+ VERBOSE_OUT(1)<<program<<": "<<task<<std::endl;
+ return true;
+ }
+
+ virtual bool
+ error(const String &task)
+ {
+ std::cerr<<program<<": "<<_("error")<<": "<<task<<std::endl;
+ return true;
+ }
+
+ virtual bool
+ warning(const String &task)
+ {
+ std::cerr<<program<<": "<<_("warning")<<": "<<task<<std::endl;
+ return true;
+ }
+
+ virtual bool
+ amount_complete(int /*current*/, int /*total*/)
+ {
+ return true;
+ }
+};
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file tool/renderprogress.h
+** \brief RenderProgress class
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007, 2008 Chris Moore
+**
+** 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
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_RENDERPROGRESS_H
+#define __SYNFIG_RENDERPROGRESS_H
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+#include <synfig/string.h>
+#include "definitions.h"
+
+class RenderProgress : public synfig::ProgressCallback
+{
+ string taskname;
+
+ etl::clock clk;
+ int clk_scanline; // The scanline at which the clock was reset
+ etl::clock clk2;
+
+ float last_time;
+public:
+
+ RenderProgress():clk_scanline(0), last_time(0) { }
+
+ virtual bool
+ task(const String &thetask)
+ {
+ taskname=thetask;
+ return true;
+ }
+
+ virtual bool
+ error(const String &task)
+ {
+ std::cout<<_("error")<<": "<<task<<std::endl;
+ return true;
+ }
+
+ virtual bool
+ warning(const String &task)
+ {
+ std::cout<<_("warning")<<": "<<task<<std::endl;
+ return true;
+ }
+
+ virtual bool
+ amount_complete(int scanline, int h)
+ {
+ if(be_quiet)return true;
+ if(scanline!=h)
+ {
+ const float time(clk()*(float)(h-scanline)/(float)(scanline-clk_scanline));
+ const float delta(time-last_time);
+
+ int weeks=0,days=0,hours=0,minutes=0,seconds=0;
+
+ last_time=time;
+
+ if(clk2()<0.2)
+ return true;
+ clk2.reset();
+
+ if(scanline)
+ seconds=(int)time+1;
+ else
+ {
+ //cerr<<"reset"<<endl;
+ clk.reset();
+ clk_scanline=scanline;
+ }
+
+ if(seconds<0)
+ {
+ clk.reset();
+ clk_scanline=scanline;
+ seconds=0;
+ }
+ while(seconds>=60)
+ minutes++,seconds-=60;
+ while(minutes>=60)
+ hours++,minutes-=60;
+ while(hours>=24)
+ days++,hours-=24;
+ while(days>=7)
+ weeks++,days-=7;
+
+ cerr<<taskname<<": "<<_("Line")<<" "<<scanline<<_(" of ")<<h<<" -- ";
+ //cerr<<time/(h-clk_scanline)<<" ";
+ /*
+ if(delta>=-time/(h-clk_scanline) )
+ cerr<<">";
+ */
+ if(delta>=0 && clk()>4.0 && scanline>clk_scanline+200)
+ {
+ //cerr<<"reset"<<endl;
+ clk.reset();
+ clk_scanline=scanline;
+ }
+
+ if(weeks)
+ cerr<<weeks<<"w ";
+ if(days)
+ cerr<<days<<"d ";
+ if(hours)
+ cerr<<hours<<"h ";
+ if(minutes)
+ cerr<<minutes<<"m ";
+ if(seconds)
+ cerr<<seconds<<"s ";
+
+ cerr<<" \r";
+ }
+ else
+ cerr<<taskname<<": "<<_("DONE")<<" "<<endl;;
+ return true;
+ }
+};
+
+#endif
dialog_preview.h \
dialog_setup.h \
dialog_soundselect.h \
+ dialog_targetparam.h \
dialog_waypoint.h
DIALOG_CC = \
dialog_preview.cpp \
dialog_setup.cpp \
dialog_soundselect.cpp \
+ dialog_targetparam.cpp \
dialog_waypoint.cpp
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file dialog_targetparam.cpp
+** \brief Implementation for the TargetParam Dialog
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2010 Carlos López González
+**
+** 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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "dialog_targetparam.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+//! Allowed video codecs
+/*! \warning This variable is linked to allowed_video_codecs_description,
+ * if you change this you must change the other acordingly.
+ * \warning These codecs are linked to the filename extensions for
+ * mod_ffmpeg. If you change this you must change the others acordingly.
+ */
+const char* allowed_video_codecs[] =
+{
+ "flv", "h263p", "huffyuv", "libtheora", "libx264", "libxvid",
+ "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
+ "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", NULL
+};
+
+//! Allowed video codecs description.
+/*! \warning This variable is linked to allowed_video_codecs,
+ * if you change this you must change the other acordingly.
+ */
+const char* allowed_video_codecs_description[] =
+{
+ "Flash Video (FLV) / Sorenson Spark / Sorenson H.263.",
+ "H.263+ / H.263-1998 / H.263 version 2.",
+ "Huffyuv / HuffYUV.",
+ "libtheora Theora.",
+ "libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10.",
+ "libxvidcore MPEG-4 part 2.",
+ "MJPEG (Motion JPEG).",
+ "raw MPEG-1 video.",
+ "raw MPEG-2 video.",
+ "MPEG-4 part 2.",
+ "MPEG-4 part 2 Microsoft variant version 3.",
+ "MPEG-4 part 2 Microsoft variant version 1.",
+ "MPEG-4 part 2 Microsoft variant version 2.",
+ "Windows Media Video 7.",
+ "Windows Media Video 8.",
+ NULL
+};
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+Dialog_TargetParam::Dialog_TargetParam(synfig::TargetParam &tparam)
+{
+ set_title("TargetParam Dialog");
+ set_tparam(tparam);
+ // Available Video Codecs Combo Box Text.
+ vcodec = Gtk::manage(new Gtk::ComboBoxText());
+ Gtk::Label* label(manage(new Gtk::Label(_("Available Video Codecs:"))));
+ label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+ get_vbox()->pack_start(*label, true, true, 0);
+ for (int i = 0; allowed_video_codecs[i] != NULL &&
+ allowed_video_codecs_description[i] != NULL; i++)
+ vcodec->append_text(allowed_video_codecs_description[i]);
+ for (int i = 0; allowed_video_codecs[i] != NULL &&
+ allowed_video_codecs_description[i] != NULL; i++)
+ if(!get_tparam().video_codec.compare(allowed_video_codecs[i]))
+ vcodec->set_active_text(allowed_video_codecs_description[i]);
+
+ get_vbox()->pack_start(*vcodec, true, true, 0);
+
+ //Bitrate Spin Button
+ Gtk::Adjustment* bradj(manage(new class Gtk::Adjustment(double(tparam.bitrate), 10.0,1000.0)));
+ bitrate = Gtk::manage(new class Gtk::SpinButton(*bradj));
+ Gtk::Label* label2(manage(new Gtk::Label(_("Video Bit Rate:"))));
+ label2->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+ get_vbox()->pack_start(*label2, true, true, 0);
+ get_vbox()->pack_start(*bitrate,true, true, 0);
+
+ get_vbox()->show_all();
+
+ ok_button = manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+ ok_button->show();
+ add_action_widget(*ok_button,Gtk::RESPONSE_OK);
+ ok_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_ok));
+
+ cancel_button = manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ cancel_button->show();
+ add_action_widget(*cancel_button,Gtk::RESPONSE_CANCEL);
+ cancel_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_cancel));
+
+}
+
+void
+Dialog_TargetParam::on_ok()
+{
+ std::string codecnamed = vcodec->get_active_text();
+ for (int i = 0; allowed_video_codecs[i] != NULL &&
+ allowed_video_codecs_description[i] != NULL; i++)
+ if(!codecnamed.compare(allowed_video_codecs_description[i]))
+ tparam_.video_codec=allowed_video_codecs[i];
+ tparam_.bitrate=bitrate->get_value();
+ hide();
+}
+
+void
+Dialog_TargetParam::on_cancel()
+{
+ hide();
+}
+
+Dialog_TargetParam::~Dialog_TargetParam()
+{
+}
+
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file dialog_targetparam.h
+** \brief Targetparam Dialog Header
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2010 Carlos López González
+**
+** 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_STUDIO_DIALOG_TARGETPARAM_H
+#define __SYNFIG_STUDIO_DIALOG_TARGETPARAM_H
+
+/* === H E A D E R S ======================================================= */
+#include <gtkmm/dialog.h>
+#include <gtkmm/button.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/spinbutton.h>
+
+#include <synfig/targetparam.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace studio {
+
+class Dialog_TargetParam : public Gtk::Dialog
+{
+ synfig::TargetParam tparam_;
+ Gtk::Button *ok_button;
+ Gtk::Button *cancel_button;
+ Gtk::SpinButton *bitrate;
+ Gtk::ComboBoxText *vcodec;
+
+ void on_ok();
+ void on_cancel();
+
+public:
+ Dialog_TargetParam(synfig::TargetParam &tparam);
+ ~Dialog_TargetParam();
+
+ synfig::TargetParam get_tparam() const { return tparam_; }
+ void set_tparam(const synfig::TargetParam &tp) {tparam_=tp; }
+
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
+
+
+
#include <synfig/target_scanline.h>
#include <synfig/canvas.h>
#include "asyncrenderer.h"
+#include "dialog_targetparam.h"
#include "general.h"
entry_quality(adjustment_quality,1,0),
adjustment_antialias(1,1,31),
entry_antialias(adjustment_antialias,1,0),
- toggle_single_frame(_("Use _current frame"), true)
+ toggle_single_frame(_("Use _current frame"), true),
+ tparam("libxvid",200)
{
widget_rend_desc.show();
widget_rend_desc.signal_changed().connect(sigc::mem_fun(*this,&studio::RenderSettings::on_rend_desc_changed));
choose_button->show();
choose_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_choose_pressed));
+ Gtk::Button *tparam_button(manage(new class Gtk::Button(Gtk::StockID(_("Parameters...")))));
+ tparam_button->show();
+ tparam_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_targetparam_pressed));
+
Gtk::Frame *target_frame=manage(new Gtk::Frame(_("Target")));
target_frame->set_shadow_type(Gtk::SHADOW_NONE);
((Gtk::Label *) target_frame->get_label_widget())->set_markup(_("<b>Target</b>"));
targetLabel->set_alignment(0, 0.5);
targetLabel->set_mnemonic_widget(optionmenu_target);
target_table->attach(*targetLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- target_table->attach(optionmenu_target, 1, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ target_table->attach(optionmenu_target, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ target_table->attach(*tparam_button, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
toggle_single_frame.signal_toggled().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_single_frame_toggle));
}
void
+RenderSettings::on_targetparam_pressed()
+{
+ Dialog_TargetParam *dialogtp = new Dialog_TargetParam(tparam);
+ if(dialogtp->run()==Gtk::RESPONSE_OK)
+ tparam=dialogtp->get_tparam();
+
+ delete dialogtp;
+}
+
+void
RenderSettings::on_render_pressed()
{
String filename=entry_filename.get_text();
return;
}
- Target::Handle target=Target::create(calculated_target_name,filename);
+ Target::Handle target=Target::create(calculated_target_name,filename, tparam);
if(!target)
{
canvas_interface_->get_ui_interface()->error(_("Unable to create target for ")+filename);
#include <gtkmm/optionmenu.h>
#include <synfig/string.h>
+#include <synfig/targetparam.h>
#include <synfigapp/canvasinterface.h>
etl::handle<AsyncRenderer> async_renderer;
+ synfig::TargetParam tparam;
+
public:
RenderSettings(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface);
~RenderSettings();
void on_choose_pressed();
void on_render_pressed();
void on_cancel_pressed();
+ void on_targetparam_pressed();
void on_finished();
}; // END of class RenderSettings