summaryrefslogtreecommitdiff
authorNicolas George <nicolas.george@normalesup.org>2013-02-27 20:14:48 (GMT)
committer Nicolas George <nicolas.george@normalesup.org>2013-03-10 12:48:49 (GMT)
commitcb2bd91413af28ca9a0202e9b92ee7c1e3d9dd2e (patch)
treed57b5a4f87bb1f9730a2f06b6b42a25b27c4d93a
parentf9b34b8bf967e8e80df9bcb4a16556a9d4526484 (diff)
downloadffmpeg-cb2bd91413af28ca9a0202e9b92ee7c1e3d9dd2e.zip
ffmpeg-cb2bd91413af28ca9a0202e9b92ee7c1e3d9dd2e.tar.gz
ffmpeg-cb2bd91413af28ca9a0202e9b92ee7c1e3d9dd2e.tar.bz2
ffmpeg: add the -canvas_size option.
Allows, amongst other things, to override the size guessed by the sub2video hack. Note: the -s option could have more or less the same semantic, but it receives a special treatment by the options system.
Diffstat
-rw-r--r--doc/ffmpeg.texi3
-rw-r--r--ffmpeg.h2
-rw-r--r--ffmpeg_opt.c12
3 files changed, 16 insertions, 1 deletions
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index d52df9b..9848e0d 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -681,6 +681,9 @@ Note that this option will delay the output of all data until the next
subtitle packet is decoded: it may increase memory consumption and latency a
lot.
+@item -canvas_size @var{size}
+Set the size of the canvas used to render subtitles.
+
@end table
@section Advanced options
diff --git a/ffmpeg.h b/ffmpeg.h
index a04913e..95c2aa6 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -169,6 +169,8 @@ typedef struct OptionsContext {
int nb_reinit_filters;
SpecifierOpt *fix_sub_duration;
int nb_fix_sub_duration;
+ SpecifierOpt *canvas_sizes;
+ int nb_canvas_sizes;
SpecifierOpt *pass;
int nb_pass;
SpecifierOpt *passlogfiles;
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 2d890cf..ebaf88d 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -617,11 +617,19 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
break;
case AVMEDIA_TYPE_DATA:
- case AVMEDIA_TYPE_SUBTITLE:
+ case AVMEDIA_TYPE_SUBTITLE: {
+ char *canvas_size = NULL;
if(!ist->dec)
ist->dec = avcodec_find_decoder(dec->codec_id);
MATCH_PER_STREAM_OPT(fix_sub_duration, i, ist->fix_sub_duration, ic, st);
+ MATCH_PER_STREAM_OPT(canvas_sizes, str, canvas_size, ic, st);
+ if (canvas_size &&
+ av_parse_video_size(&dec->width, &dec->height, canvas_size) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size);
+ exit(1);
+ }
break;
+ }
case AVMEDIA_TYPE_ATTACHMENT:
case AVMEDIA_TYPE_UNKNOWN:
break;
@@ -2593,6 +2601,8 @@ const OptionDef options[] = {
, "force subtitle tag/fourcc", "fourcc/tag" },
{ "fix_sub_duration", OPT_BOOL | OPT_EXPERT | OPT_SUBTITLE | OPT_SPEC, { .off = OFFSET(fix_sub_duration) },
"fix subtitles duration" },
+ { "canvas_size", OPT_SUBTITLE | HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(canvas_sizes) },
+ "set canvas size (WxH or abbreviation)", "size" },
/* grab options */
{ "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_video_channel },