[FFmpeg-cvslog] avconv: add -n option to immediately exit when output files already exist

Vittorio Giovara git at videolan.org
Thu Aug 1 13:21:47 CEST 2013


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Wed Jul 31 14:48:49 2013 +0200| [7748dd41be3d6dd6300f14263586af4ee104ead2] | committer: Martin Storsjö

avconv: add -n option to immediately exit when output files already exist

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7748dd41be3d6dd6300f14263586af4ee104ead2
---

 Changelog       |    1 +
 avconv_opt.c    |   10 +++++++++-
 doc/avconv.texi |    3 +++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index faf0393..37e5a60 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version 10:
 - support for WavPack muxing (raw and in Matroska)
 - Go2Webinar decoder
 - WavPack encoding through libwavpack
+- Added the -n parameter to avconv
 
 
 version 9:
diff --git a/avconv_opt.c b/avconv_opt.c
index 96ec0d3..f96fece 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -71,6 +71,7 @@ int print_stats       = 1;
 int qp_hist           = 0;
 
 static int file_overwrite     = 0;
+static int file_skip          = 0;
 static int video_discard      = 0;
 static int intra_dc_precision = 8;
 static int using_stdin        = 0;
@@ -508,11 +509,16 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
 
 static void assert_file_overwrite(const char *filename)
 {
+    if (file_overwrite && file_skip) {
+        fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
+        exit_program(1);
+    }
+
     if (!file_overwrite &&
         (strchr(filename, ':') == NULL || filename[1] == ':' ||
          av_strstart(filename, "file:", NULL))) {
         if (avio_check(filename, 0) == 0) {
-            if (!using_stdin) {
+            if (!using_stdin && !file_skip) {
                 fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
                 fflush(stderr);
                 if (!read_yesno()) {
@@ -2113,6 +2119,8 @@ const OptionDef options[] = {
         "force format", "fmt" },
     { "y",              OPT_BOOL,                                    {              &file_overwrite },
         "overwrite output files" },
+    { "n",              OPT_BOOL,                                    {              &file_skip },
+        "never overwrite output files" },
     { "c",              HAS_ARG | OPT_STRING | OPT_SPEC |
                         OPT_INPUT | OPT_OUTPUT,                      { .off       = OFFSET(codec_names) },
         "codec name", "codec" },
diff --git a/doc/avconv.texi b/doc/avconv.texi
index 1842422..940c188 100644
--- a/doc/avconv.texi
+++ b/doc/avconv.texi
@@ -233,6 +233,9 @@ input file name
 @item -y (@emph{global})
 Overwrite output files without asking.
 
+ at item -n (@emph{global})
+Immediately exit when output files already exist.
+
 @item -c[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream})
 @itemx -codec[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream})
 Select an encoder (when used before an output file) or a decoder (when used



More information about the ffmpeg-cvslog mailing list