Patch to add a quiet flag to CLI

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
nikwest
Posts: 14
Joined: Fri Feb 23, 2007 8:27 pm

Patch to add a quiet flag to CLI

Post by nikwest »

Hi,

running MediaForkCLI with XGrid makes a lot of noise updating the status.
I added a quiet flag to make the output less verbouse.

NikWest

Code: Select all

Index: test/test.c
===================================================================
--- test/test.c	(revision 374)
+++ test/test.c	(working copy)
@@ -43,11 +43,14 @@
 static int    chapter_start = 0;
 static int    chapter_end   = 0;
 static int	  crf			= 0;
+static int	  quiet			= 0;
 
 /* Exit cleanly on Ctrl-C */
 static volatile int die = 0;
 static void SigHandler( int );
 
+static float lastprogess=0.0;
+
 /* Utils */
 static void ShowCommands();
 static void ShowHelp();
@@ -439,9 +442,13 @@
 
 #define p s.param.working
         case HB_STATE_WORKING:
+			if(quiet && p.progress <= lastprogess) {
+				break;
+			}
+			lastprogess+=0.01;
             fprintf( stderr, "\rEncoding: task %d of %d, %.2f %%",
                      p.job_cur, p.job_count, 100.0 * p.progress );
-            if( p.seconds > -1 )
+            if( p.seconds > -1)
             {
                 fprintf( stderr, " (%.2f fps, avg %.2f fps, ETA "
                          "%02dh%02dm%02ds)", p.rate_cur, p.rate_avg,
@@ -512,7 +519,8 @@
     "\n"
     "    -h, --help              Print help\n"
     "    -u, --update            Check for updates and exit\n"
-    "    -v, --verbose           Be verbose\n"
+	"    -v, --verbose           Be verbose\n"
+	"    -V, --quiet             Be quiet\n"
     "    -C, --cpu               Set CPU count (default: autodetected)\n"
     "\n"
     "    -f, --format <string>   Set output format (avi/mp4/ogm, default:\n"
@@ -575,7 +583,8 @@
           {
             { "help",        no_argument,       NULL,    'h' },
             { "update",      no_argument,       NULL,    'u' },
-            { "verbose",     no_argument,       NULL,    'v' },
+			{ "verbose",     no_argument,       NULL,    'v' },
+			{ "quiet",		 no_argument,       NULL,    'V' },
             { "cpu",         required_argument, NULL,    'C' },
 
             { "format",      required_argument, NULL,    'f' },
@@ -612,7 +621,7 @@
         int c;
 
         c = getopt_long( argc, argv,
-                         "hvuC:f:i:o:t:c:a:s:e:E:2dgpw:l:n:b:q:S:B:r:R:Q",
+                         "hvVuC:f:i:o:t:c:a:s:e:E:2dgpw:l:n:b:q:S:B:r:R:Q",
                          long_options, &option_index );
         if( c < 0 )
         {
@@ -630,6 +639,9 @@
             case 'v':
                 debug = HB_DEBUG_ALL;
                 break;
+            case 'V':
+                quiet = 1;
+                break;
             case 'C':
                 cpu = atoi( optarg );
                 break;

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: Patch to add a quiet flag to CLI

Post by jbrjake »

nikwest wrote:I added a quiet flag to make the output less verbouse.
Now that sr55 has the CLI help cleaned up and organized, I figured this would be a good time to commit this.

nikwest, how is this supposed to function? I just patched it into the latest source, and while it reduces the frequency of the progress updates, it doesn't not stop them completely.

Is that how it's supposed to work, just lessening the frequency of updates? Or should it be displaying no progress at all until the encode is finished?

Trying to figure out whether to check this into the SVN as-is.
tubbyman
Posts: 42
Joined: Mon Apr 09, 2007 3:39 am

Post by tubbyman »

I also saw this with xgrid. A simple solution is to redirect unwanted output to /dev/null.

The larger question that I have is about distributed processing. CLI users will be using rsh/ssh with forks to distribute jobs around the network, and users like you and I may even be able to use xgrid, but what about the GUI users? I would love to see an mDNSResponder/Bonjour/ZeroConf implementation get into the GUI so that all users could take advantage of all of the computers in their house. I'm just yapping here; but Hell, it's 1:30 in the AM. If you can't yap at 1:30 AM, when can you yap?
nikwest
Posts: 14
Joined: Fri Feb 23, 2007 8:27 pm

Re: Patch to add a quiet flag to CLI

Post by nikwest »

jbrjake wrote:
nikwest wrote:I added a quiet flag to make the output less verbouse.
Now that sr55 has the CLI help cleaned up and organized, I figured this would be a good time to commit this.

nikwest, how is this supposed to function? I just patched it into the latest source, and while it reduces the frequency of the progress updates, it doesn't not stop them completely.

Is that how it's supposed to work, just lessening the frequency of updates? Or should it be displaying no progress at all until the encode is finished?

Trying to figure out whether to check this into the SVN as-is.
Hi,

sorry haven't read the forum for quite a while. Yes, it just reduces the frequency. Not sure if anybody needs it, I needed it to keep my xgrid output low. I did not want to send it to /dev/null completely but still have at least some output to implement progess bar etc.

NikWest
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: Patch to add a quiet flag to CLI

Post by jbrjake »

nikwest wrote:Yes, it just reduces the frequency.
Cool, I'll make sure to commit it, then, after we get this first 0.8.5 beta out. PM me with your name/email as you want it in the AUTHORS file.
Post Reply