Created
November 27, 2018 13:27
-
-
Save ManasJayanth/4fcc1c69ff8ad7409af7a29bdb7f7fc5 to your computer and use it in GitHub Desktop.
Interpolation of values in effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ges/ges.h> | |
#include <string.h> | |
#include <stdlib.h> | |
char input_file[256], output_file[256]; | |
void | |
control_binding_added_handler (GESTrackElement *track_element, | |
GstControlBinding *control_binding, | |
gpointer user_data) { | |
GstObject *o; | |
GstControlSource *csource; | |
g_object_get(control_binding, "control_source", &csource, NULL); | |
g_print("Control binding: %s\n", G_OBJECT_TYPE_NAME(csource)); | |
if (gst_timed_value_control_source_set ((GstTimedValueControlSource *) csource, | |
0, | |
1) != TRUE) { | |
g_print("Initial failed\n"); | |
}; | |
if (gst_timed_value_control_source_set ((GstTimedValueControlSource *) csource, | |
2 * GST_SECOND, | |
0) != TRUE) { | |
g_print("Final failed\n"); | |
} | |
} | |
void | |
video_track_element_added (GESTrack *object, | |
GESTrackElement *timeline_element, | |
gpointer user_data) { | |
g_print("track element added %s\n", G_OBJECT_TYPE_NAME(timeline_element)); | |
/* if (strcmp("GESEffect", G_OBJECT_TYPE_NAME(timeline_element)) != 0) { */ | |
/* return; */ | |
/* } */ | |
GstClockTime start = ges_timeline_element_get_start ((GESTimelineElement *)timeline_element); | |
g_print("Got text starting at %llu\n", start / GST_SECOND); | |
GstControlSource *csource = gst_interpolation_control_source_new (); | |
g_object_set(csource, | |
"mode", GST_INTERPOLATION_MODE_LINEAR, | |
NULL); | |
// boolean return | |
g_signal_connect(timeline_element, "control-binding-added", (GCallback) control_binding_added_handler, NULL); | |
if ( ges_track_element_set_control_source (timeline_element, | |
csource, | |
"alpha", | |
"direct") == FALSE) { | |
g_print(">>>>>>> failed\n"); | |
} else { | |
g_print("Rotated \n"); | |
} | |
} | |
int main(int argc, char** argv) { | |
GMainLoop *mainloop; | |
GESLayer *layer; | |
GESTimeline *timeline; | |
GESClip *clip, *effect_clip; | |
GESPipeline *pipeline; | |
GESTrack *v, *a; | |
strcat(input_file, "file://"); | |
strcat(input_file, getenv("PWD")); | |
strcat(input_file, "/input.jpg"); | |
/* strcat(output_file, "file://"); */ | |
/* strcat(output_file, getenv("PWD")); */ | |
/* strcat(output_file, "/output.mp4"); */ | |
gst_init (NULL, NULL); | |
ges_init (); | |
v = GES_TRACK(ges_video_track_new ()); | |
g_signal_connect(v, "track-element-added", (GCallback) video_track_element_added, NULL); | |
a = GES_TRACK(ges_audio_track_new ()); | |
timeline = ges_timeline_new (); | |
ges_timeline_add_track(timeline, v); | |
ges_timeline_add_track(timeline, a); | |
layer = ges_layer_new (); | |
g_object_set (layer, "priority", (gint32) 0, NULL); | |
ges_timeline_add_layer (timeline, layer); | |
pipeline = ges_pipeline_new (); | |
ges_pipeline_set_mode (pipeline, GES_PIPELINE_MODE_PREVIEW); | |
ges_pipeline_set_timeline (pipeline, timeline); | |
clip = GES_CLIP (ges_uri_clip_new (input_file)); | |
guint64 duration = 3 * GST_SECOND; | |
g_object_set (clip, | |
"start", (guint64) 0, | |
"duration", (guint64) duration, | |
"priority", (guint32) 1, | |
"in-point", (guint64) 0, | |
NULL); | |
ges_layer_add_clip (layer, clip); | |
mainloop = g_main_loop_new (NULL, FALSE); | |
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); | |
g_main_loop_run (mainloop); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ges/ges.h> | |
#include <string.h> | |
#include <stdlib.h> | |
char input_file[256], output_file[256]; | |
void | |
control_binding_added_handler (GESTrackElement *track_element, | |
GstControlBinding *control_binding, | |
gpointer user_data) { | |
GstObject *o; | |
GstControlSource *csource; | |
g_object_get(control_binding, "control_source", &csource, NULL); | |
g_print("Control binding: %s\n", G_OBJECT_TYPE_NAME(csource)); | |
if (gst_timed_value_control_source_set ((GstTimedValueControlSource *) csource, | |
0, | |
0) != TRUE) { | |
g_print("Initial failed\n"); | |
}; | |
if (gst_timed_value_control_source_set ((GstTimedValueControlSource *) csource, | |
2 * GST_SECOND, | |
0.2) != TRUE) { | |
g_print("Final failed\n"); | |
} | |
} | |
void | |
video_track_element_added (GESTrack *object, | |
GESTrackElement *timeline_element, | |
gpointer user_data) { | |
g_print("track element added %s\n", G_OBJECT_TYPE_NAME(timeline_element)); | |
if (strcmp("GESEffect", G_OBJECT_TYPE_NAME(timeline_element)) != 0) { | |
return; | |
} | |
GstClockTime start = ges_timeline_element_get_start ((GESTimelineElement *)timeline_element); | |
g_print("Got text starting at %llu\n", start / GST_SECOND); | |
GstControlSource *csource = gst_interpolation_control_source_new (); | |
g_object_set(csource, | |
"mode", GST_INTERPOLATION_MODE_LINEAR, | |
NULL); | |
// boolean return | |
g_signal_connect(timeline_element, "control-binding-added", (GCallback) control_binding_added_handler, NULL); | |
if ( ges_track_element_set_control_source (timeline_element, | |
csource, | |
"angle", | |
"direct") == FALSE) { | |
g_print(">>>>>>> failed\n"); | |
} else { | |
g_print("Rotated \n"); | |
} | |
} | |
int main(int argc, char** argv) { | |
GMainLoop *mainloop; | |
GESLayer *layer; | |
GESTimeline *timeline; | |
GESClip *clip, *effect_clip; | |
GESPipeline *pipeline; | |
GESTrack *v, *a; | |
strcat(input_file, "file://"); | |
strcat(input_file, getenv("PWD")); | |
strcat(input_file, "/input.jpg"); | |
/* strcat(output_file, "file://"); */ | |
/* strcat(output_file, getenv("PWD")); */ | |
/* strcat(output_file, "/output.mp4"); */ | |
gst_init (NULL, NULL); | |
ges_init (); | |
v = GES_TRACK(ges_video_track_new ()); | |
g_signal_connect(v, "track-element-added", (GCallback) video_track_element_added, NULL); | |
a = GES_TRACK(ges_audio_track_new ()); | |
timeline = ges_timeline_new (); | |
ges_timeline_add_track(timeline, v); | |
ges_timeline_add_track(timeline, a); | |
layer = ges_layer_new (); | |
g_object_set (layer, "priority", (gint32) 0, NULL); | |
ges_timeline_add_layer (timeline, layer); | |
pipeline = ges_pipeline_new (); | |
ges_pipeline_set_mode (pipeline, GES_PIPELINE_MODE_PREVIEW); | |
ges_pipeline_set_timeline (pipeline, timeline); | |
clip = GES_CLIP (ges_uri_clip_new (input_file)); | |
guint64 duration = 3 * GST_SECOND; | |
g_object_set (clip, | |
"start", (guint64) 0, | |
"duration", (guint64) duration, | |
"priority", (guint32) 1, | |
"in-point", (guint64) 0, | |
NULL); | |
ges_layer_add_clip (layer, clip); | |
effect_clip = GES_CLIP(ges_effect_clip_new ("rotate angle=0.2", NULL)); | |
g_object_set (effect_clip, | |
"start", (guint64) 0, | |
"duration", duration, | |
"priority", (guint32) 0, | |
"in-point", (guint64) 0, | |
NULL); | |
ges_layer_add_clip (layer, effect_clip); | |
mainloop = g_main_loop_new (NULL, FALSE); | |
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); | |
g_main_loop_run (mainloop); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment