[longomatch] libcesarplayer: add a simple test for the editor
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] libcesarplayer: add a simple test for the editor
- Date: Sat, 27 Oct 2012 15:12:57 +0000 (UTC)
commit e8803ca1a28c055c66fdf7843580ba79c6ac5430
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sat Oct 27 17:11:22 2012 +0200
libcesarplayer: add a simple test for the editor
libcesarplayer/test-editor.c | 106 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 106 insertions(+), 0 deletions(-)
---
diff --git a/libcesarplayer/test-editor.c b/libcesarplayer/test-editor.c
new file mode 100644
index 0000000..afc2d24
--- /dev/null
+++ b/libcesarplayer/test-editor.c
@@ -0,0 +1,106 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * main.c
+ * Copyright (C) Andoni Morales Alastruey 2008 <ylatuya gmail com>
+ *
+ * main.c is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * main.c is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Compile with:
+ * gcc -o test-editor test-remuxer.c gst-remuxer.c `pkg-config --cflags --libs gstreamer-0.10` -DOSTYPE_LINUX -O0 -g
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <gst/gst.h>
+#include "gst-video-editor.h"
+
+static GMainLoop *loop;
+
+static gboolean
+percent_done_cb (GstVideoEditor *remuxer, gfloat percent, GstVideoEditor *editor)
+{
+ if (percent == 1) {
+ g_print("SUCESS!\n");
+ g_main_loop_quit (loop);
+ } else {
+ g_print("----> %f%%", percent);
+ }
+}
+
+static gboolean
+error_cb (GstVideoEditor *remuxer, gchar *error, GstVideoEditor *editor)
+{
+ g_print("ERROR: %s\n", error);
+ g_main_loop_quit (loop);
+}
+
+int
+main (int argc, char *argv[])
+{
+ GstVideoEditor *editor;
+ VideoEncoderType video_encoder;
+ VideoMuxerType video_muxer;
+ AudioEncoderType audio_encoder;
+ gchar *input_file, *output_file;
+ gchar *err = NULL;
+
+ gst_video_editor_init_backend (&argc, &argv);
+
+ if (argc != 4) {
+ g_print("Usage: test-remuxer input_file output_file format\n");
+ return 1;
+ }
+ input_file = argv[1];
+ output_file = argv[2];
+
+ if (!g_strcmp0(argv[3], "mp4")) {
+ video_encoder = VIDEO_ENCODER_H264;
+ video_muxer = VIDEO_MUXER_MP4;
+ audio_encoder = AUDIO_ENCODER_AAC;
+ } else {
+ err = g_strdup_printf ("Invalid format %s\n", argv[3]);
+ goto error;
+ }
+
+ editor = gst_video_editor_new (NULL);
+ gst_video_editor_set_video_encoder (editor, &err, video_encoder);
+ if (err != NULL)
+ goto error;
+ gst_video_editor_set_audio_encoder (editor, &err, audio_encoder);
+ if (err != NULL)
+ goto error;
+ gst_video_editor_set_video_muxer (editor, &err, video_muxer);
+ if (err != NULL)
+ goto error;
+ gst_video_editor_add_segment (editor, input_file, 5000, 50000,
+ (gdouble) 1, "Test", TRUE);
+ g_object_set (editor, "output_file", output_file,
+ "width", 320, "height", 240, "enable-audio", FALSE, NULL);
+
+ loop = g_main_loop_new (NULL, FALSE);
+ g_signal_connect (editor, "error", G_CALLBACK (error_cb), editor);
+ g_signal_connect (editor, "percent_completed", G_CALLBACK(percent_done_cb),
+ editor);
+ gst_video_editor_start (editor);
+ g_main_loop_run (loop);
+
+ return 0;
+
+error:
+ g_print ("ERROR: %s", err);
+ return 1;
+
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]