[svn r714] version increased to 0.3. test binary removed from debian package
13 static GMainLoop *mainloop = NULL;
15 static gchar* input_file = NULL;
16 static gchar* video_encode = NULL;
17 static gchar* video_opts = NULL;
18 static gdouble video_fps = 0.0;
19 static gint video_rate = 0;
20 static gint video_width = 0;
21 static gint video_height = 0;
22 static gchar* audio_encode = NULL;
23 static gchar* audio_opts = NULL;
24 static double audio_rate = 0.0;
25 static gchar* mux_name = NULL;
26 static gchar* output_uri = NULL;
33 g_object_unref (data);
34 g_main_loop_quit (mainloop);
39 _mencoder_eos_cb (GMencoder *mencoder, gpointer data)
42 g_idle_add (_quit, mencoder);
47 _mencoder_error_cb (GMencoder *mencoder, const gchar* msg, gpointer data)
49 g_print ("Error: %s\n", msg);
50 g_idle_add (_quit, mencoder);
54 _io_channel_cb (GIOChannel *ch,
55 GIOCondition condition,
58 GString *cmd = g_string_new ("");
59 g_io_channel_read_line_string (ch, cmd, NULL, NULL);
61 if (strcmp (cmd->str, "PLAY\n") == 0) {
62 g_mencoder_play_stream (G_MENCODER (data));
63 } else if (strcmp (cmd->str, "PAUSE\n") == 0) {
64 g_mencoder_pause_stream (G_MENCODER (data));
65 } else if (strcmp (cmd->str, "STOP\n") == 0) {
66 g_mencoder_close_stream (G_MENCODER (data));
67 } else if (strcmp (cmd->str, "QUIT\n") == 0) {
68 g_mencoder_close_stream (G_MENCODER (data));
69 g_main_loop_quit (mainloop);
71 g_string_free (cmd, TRUE);
76 main (int argc, char** argv)
78 GMencoder *coder = NULL;
85 GOptionContext *context;
86 static const GOptionEntry options [] = {
87 {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file, "Input File", NULL},
88 {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode, "GstElementName for used to video encode", NULL},
89 {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts, "Properties to set on video element", NULL},
90 {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps, "Video FPS", NULL},
91 {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate, "Video rate", NULL},
92 {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width, "Video width", NULL},
93 {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height, "Video height", NULL},
94 {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode, "GstElementName for use to audio encode", NULL},
95 {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts, "Properties to set on audio element", NULL},
96 {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate, "Audio rate", NULL},
97 {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name, "GstElementName for use to mux file", NULL},
98 {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri, "Uri to output", NULL},
103 g_thread_init (NULL);
104 mainloop = g_main_loop_new (NULL, FALSE);
106 g_set_prgname ("gmemcoder");
107 context = g_option_context_new (NULL);
108 g_option_context_set_help_enabled (context, TRUE);
109 g_option_context_add_main_entries (context, options, NULL);
110 g_option_context_add_group (context, gst_init_get_option_group ());
111 g_option_context_parse (context, &argc, &argv, NULL);
113 gst_init (&argc, &argv);
115 if (output_uri == NULL) {
116 g_print ("You need specify output-uri.\nTry --help for more information.\n");
120 if (input_file == NULL) {
121 g_print ("You need specify input file\nTry --help for more information.\n");
124 coder = g_mencoder_new ();
125 ch = g_io_channel_unix_new (0);
127 aopts = g_strsplit (audio_opts, ",", 0);
128 vopts = g_strsplit (video_opts, ",", 0);
130 g_mencoder_setup_stream (coder,
132 video_encode, vopts, video_fps, video_rate, video_width, video_height,
133 audio_encode, aopts, audio_rate,
136 files = g_strsplit (input_file, ",", 0);
137 for (i=0; i < g_strv_length (files); i++) {
138 if (!g_mencoder_append_uri (coder, files[i])) {
139 g_debug ("Invalid uri: %s", files[i]);
148 g_io_add_watch (ch, G_IO_IN, _io_channel_cb, coder);
150 g_signal_connect (G_OBJECT (coder),
152 G_CALLBACK (_mencoder_eos_cb),
155 g_signal_connect (G_OBJECT (coder),
157 G_CALLBACK (_mencoder_error_cb),
160 g_mencoder_play_stream (coder);
162 g_debug ("RUNNING..");
163 g_main_loop_run (mainloop);
165 g_object_unref (coder);