Skip to content

Commit

Permalink
examples: add video bit-rate control to frame-counter
Browse files Browse the repository at this point in the history
  • Loading branch information
hodefoting committed Nov 27, 2015
1 parent 319d012 commit f319ffe
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions examples/frame-counter.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,46 @@
#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 */
{
GeglNode *gegl = gegl_node_new ();
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",
Expand All @@ -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++)
{
Expand Down

0 comments on commit f319ffe

Please sign in to comment.