** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
** Copyright (c) 2007, 2008 Chris Moore
+** Copyright (c) 2009-2010 Diego Barrios
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
bool be_quiet=false;
bool print_benchmarks=false;
+//! 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",
+ "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.",
+ "MJPEG (Motion JPEG).",
+ "raw MPEG-1 video.",
+ "raw MPEG-2 video.",
+ "MPEG-4 part 2. (XviD/DivX)",
+ "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
+};
+
/* === T Y P E D E F S ===================================================== */
typedef list<String> arg_list_t;
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);
if(*iter=="-t")
{
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++;
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++)
{
// 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++;
}
- return SYNFIGTOOL_OK;
+ if (need_bitrate_parameter)
+ ret = SYNFIGTOOL_MISSINGARGUMENT;
+
+ return ret;
}
int extract_append(arg_list_t &arg_list,string &filename)
// Extract the extra parameters for the targets that
// need them.
if (target_name == "ffmpeg")
- extract_target_params(imageargs, target_parameters);
+ {
+ 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