[FFmpeg-devel] [PATCH] ffplay: implement -showmode option

Stefano Sabatini stefano.sabatini-lala at poste.it
Tue Apr 12 13:11:33 CEST 2011


The new option allows to select the starting show mode.
---
 doc/ffplay.texi |   18 ++++++++++++++++++
 ffplay.c        |   14 ++++++++++++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index e0518b8..0b8c851 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -58,6 +58,24 @@ Force format.
 Set window title (default is the input filename).
 @item -loop @var{number}
 Loops movie playback <number> times. 0 means forever.
+ at item -showmode @var{mode}
+Set the show mode to use.
+Available values for @var{mode} are:
+ at table @samp
+ at item 0
+show video
+ at item 1
+show audio waves
+ at item 2
+show audio frequency band using RDFT ((Inverse) Real Discrete Fourier Transform)
+ at end table
+
+Default value is 0, if video is not present or cannot be played 2 is
+automatically selected.
+
+You can interactively cycle through the available show modes by
+pressing the key @key{w}.
+
 @item -vf @var{filter_graph}
 @var{filter_graph} is a description of the filter graph to apply to
 the input video.
diff --git a/ffplay.c b/ffplay.c
index d9aa124..3e3c451 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -170,7 +170,7 @@ typedef struct VideoState {
     AVAudioConvert *reformat_ctx;
 
     enum {
-        SHOW_MODE_VIDEO = 0, SHOW_MODE_WAVES, SHOW_MODE_RFDT, SHOW_MODE_NB
+        SHOW_MODE_VIDEO = 0, SHOW_MODE_WAVES, SHOW_MODE_RDFT, SHOW_MODE_NB
     } show_mode;
     int16_t sample_array[SAMPLE_ARRAY_SIZE];
     int sample_array_index;
@@ -267,6 +267,7 @@ static int exit_on_keydown;
 static int exit_on_mousedown;
 static int loop=1;
 static int framedrop=1;
+static int show_mode = SHOW_MODE_VIDEO;
 
 static int rdftspeed=20;
 #if CONFIG_AVFILTER
@@ -2470,6 +2471,8 @@ static int decode_thread(void *arg)
         av_dump_format(ic, 0, is->filename, 0);
     }
 
+    is->show_mode = show_mode;
+
     /* open the streams */
     if (st_index[AVMEDIA_TYPE_AUDIO] >= 0) {
         stream_component_open(is, st_index[AVMEDIA_TYPE_AUDIO]);
@@ -2482,7 +2485,7 @@ static int decode_thread(void *arg)
     is->refresh_tid = SDL_CreateThread(refresh_thread, is);
     if(ret<0) {
         if (!display_disable)
-            is->show_mode = SHOW_MODE_RFDT;
+            is->show_mode = SHOW_MODE_RDFT;
     }
 
     if (st_index[AVMEDIA_TYPE_SUBTITLE] >= 0) {
@@ -2991,6 +2994,12 @@ static int opt_thread_count(const char *opt, const char *arg)
     return 0;
 }
 
+static int opt_show_mode(const char *opt, const char *arg)
+{
+    show_mode = parse_number_or_die(opt, arg, OPT_INT, 0, SHOW_MODE_NB-1);
+    return 0;
+}
+
 static const OptionDef options[] = {
 #include "cmdutils_common_opts.h"
     { "x", HAS_ARG | OPT_FUNC2, {(void*)opt_width}, "force displayed width", "width" },
@@ -3034,6 +3043,7 @@ static const OptionDef options[] = {
     { "vf", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter list" },
 #endif
     { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, {(void*)&rdftspeed}, "rdft speed", "msecs" },
+    { "showmode", HAS_ARG | OPT_FUNC2, {(void*)opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
     { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
     { "i", OPT_DUMMY, {NULL}, "ffmpeg compatibility dummy option", ""},
     { NULL, },
-- 
1.7.2.3



More information about the ffmpeg-devel mailing list