[gegl] examples: add video bit-rate control to frame-counter



commit f319ffe75cbd82769d0aac2e52041e9389cff27b
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Nov 27 01:35:51 2015 +0100

    examples: add video bit-rate control to frame-counter

 examples/frame-counter.c |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/examples/frame-counter.c b/examples/frame-counter.c
index 6f8d126..ff628fd 100644
--- a/examples/frame-counter.c
+++ b/examples/frame-counter.c
@@ -1,14 +1,39 @@
 #include <gegl.h>
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 
 const char *output_path = "frame-counter.ogv";
+const char *video_codec = NULL;
+
+int video_bit_rate = 0;
+int video_bit_rate_min = 0;
+int video_bit_rate_max = 0;
+int bufsize = 0;
+float frame_rate = 0.0;
 
 gint
 main (gint    argc,
       gchar **argv)
 {
-  if (argv[1])
-    output_path = argv[1];
+  int c;
+  for (c = 1; argv[c]; c++)
+  {
+    if (!strcmp (argv[c], "--bufsize"))
+      bufsize = atoi(argv[++c]);
+    else if (!strcmp (argv[c], "--video_bit_rate_max"))
+      video_bit_rate_max = atoi(argv[++c]);
+    else if (!strcmp (argv[c], "--video_bit_rate_min"))
+      video_bit_rate_min = atoi(argv[++c]);
+    else if (!strcmp (argv[c], "--video-bit-rate"))
+      video_bit_rate = atoi(argv[++c]);
+    else if (!strcmp (argv[c], "--fps"))
+      frame_rate = g_strtod (argv[++c], NULL);
+    else if (!strcmp (argv[c], "--video-codec"))
+      video_codec = argv[++c];
+    else
+      output_path = argv[c];
+  }
 
   gegl_init (&argc, &argv);  /* initialize the GEGL library */
   {
@@ -16,7 +41,6 @@ main (gint    argc,
     GeglNode *store = gegl_node_new_child (gegl,
                               "operation", "gegl:ff-save",
                               "path", output_path,
-                              "frame-rate", 30.0,
                               NULL);
     GeglNode *crop    = gegl_node_new_child (gegl,
                               "operation", "gegl:crop",
@@ -36,12 +60,23 @@ main (gint    argc,
                               "value", gegl_color_new ("rgb(0.1,0.2,0.3)"),
                              NULL);
 
+    if (frame_rate)
+      gegl_node_set (store, "frame-rate", frame_rate, NULL);
+    if (bufsize)
+      gegl_node_set (store, "bufsize", bufsize, NULL);
+    if (video_bit_rate)
+      gegl_node_set (store, "video-bit-rate", video_bit_rate, NULL);
+    if (video_bit_rate_min)
+      gegl_node_set (store, "video-bit-rate-min", video_bit_rate_min, NULL);
+    if (video_bit_rate_max)
+      gegl_node_set (store, "video-bit-rate-max", video_bit_rate_max, NULL);
+
     gegl_node_link_many (bg, over, crop, store, NULL);
     gegl_node_connect_to (text, "output",  over, "aux");
 
     {
       gint frame;
-      gint frames = 400;
+      gint frames = 200;
 
       for (frame=0; frame < frames; frame++)
         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]