Created
June 13, 2016 07:43
-
-
Save tetkuz/03bc28ac4676515e83759dab29819df8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <stdio.h> | |
#include <gst/gst.h> | |
#define PIPELINE_STRING "gst-launch-1.0 \ | |
filesrc location=softboy.avi ! avidemux \ | |
! avdec_mpeg4 ! videorate \ | |
! capsfilter \ | |
caps=video/x-raw,framerate=10/1 \ | |
name=filter \ | |
! videoconvert ! ximagesink" | |
void pipeline_run(gpointer *user_data){ | |
GstElement *pipeline = (GstElement *)user_data; | |
GstBus *bus; | |
GstMessage *msg; | |
gst_element_set_state (pipeline, GST_STATE_PLAYING); | |
bus = gst_element_get_bus (pipeline); | |
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, | |
GST_MESSAGE_ERROR | GST_MESSAGE_EOS); | |
if (msg != NULL) | |
gst_message_unref (msg); | |
gst_object_unref (bus); | |
gst_element_set_state (pipeline, GST_STATE_NULL); | |
} | |
int main(int argc, char *argv[]) { | |
GstTask *task; | |
GRecMutex mutex; | |
GstElement *pipeline; | |
GstElement *filter; | |
gst_init (&argc, &argv); | |
pipeline = gst_parse_launch (PIPELINE_STRING, NULL); | |
filter = gst_bin_get_by_name(GST_BIN(pipeline), "filter"); | |
(void)filter; | |
task = gst_task_new((GstTaskFunction)pipeline_run, (gpointer)pipeline, NULL); | |
g_rec_mutex_init (&mutex); | |
gst_task_set_lock(task, &mutex); | |
gst_task_start(task); | |
do { | |
int i; | |
scanf("%d", &i); | |
if (i == -1) { | |
break; | |
} else { | |
GstCaps *caps = NULL; | |
caps = gst_caps_new_simple("video/x-raw", | |
"framerate", GST_TYPE_FRACTION, i, 1, | |
NULL); | |
g_object_set(G_OBJECT(filter), "caps", caps, NULL); | |
} | |
} while (1); | |
gst_task_join(task); | |
gst_object_unref (pipeline); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment