2010-04-20 11:08:27 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2010 Edward Hervey <bilboed@bilboed.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-04-20 11:08:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-07-07 04:21:38 +00:00
|
|
|
#include <stdio.h>
|
2010-04-20 11:08:27 +00:00
|
|
|
#include <stdlib.h>
|
2010-05-24 08:59:43 +00:00
|
|
|
#include <string.h>
|
2010-04-20 11:08:27 +00:00
|
|
|
#include <glib.h>
|
2011-12-30 16:18:18 +00:00
|
|
|
#include <glib/gprintf.h>
|
2010-04-20 11:08:27 +00:00
|
|
|
#include <ges/ges.h>
|
2010-12-15 11:36:25 +00:00
|
|
|
#include <gst/pbutils/encoding-profile.h>
|
2010-04-20 11:08:27 +00:00
|
|
|
|
2013-06-17 05:55:54 +00:00
|
|
|
#include <locale.h> /* for LC_ALL */
|
2013-09-13 21:15:21 +00:00
|
|
|
#include "ges-validate.h"
|
2014-10-30 11:38:16 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
#include <glib-unix.h>
|
|
|
|
#endif
|
|
|
|
|
2010-06-02 09:49:08 +00:00
|
|
|
/* GLOBAL VARIABLE */
|
|
|
|
static guint repeat = 0;
|
2013-09-19 23:31:10 +00:00
|
|
|
static gboolean mute = FALSE;
|
2014-04-30 18:58:42 +00:00
|
|
|
static gboolean disable_mixing = FALSE;
|
2013-07-01 14:27:54 +00:00
|
|
|
static GESPipeline *pipeline = NULL;
|
2010-09-16 07:07:05 +00:00
|
|
|
static gboolean seenerrors = FALSE;
|
2013-10-12 13:07:28 +00:00
|
|
|
static gchar *save_path = NULL;
|
2013-09-12 21:34:55 +00:00
|
|
|
static GMainLoop *mainloop;
|
2013-11-14 19:17:31 +00:00
|
|
|
static GESTrackType track_types = GES_TRACK_TYPE_AUDIO | GES_TRACK_TYPE_VIDEO;
|
2013-09-13 21:15:21 +00:00
|
|
|
static GESTimeline *timeline;
|
2014-07-27 13:42:42 +00:00
|
|
|
static gboolean needs_set_state;
|
2014-10-31 10:56:16 +00:00
|
|
|
static const gchar *scenario = NULL;
|
2010-06-02 09:49:08 +00:00
|
|
|
|
2014-10-30 11:38:16 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
static gboolean
|
|
|
|
intr_handler (gpointer user_data)
|
|
|
|
{
|
|
|
|
g_print ("interrupt received.\n");
|
|
|
|
|
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
2014-11-25 18:15:52 +00:00
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, "ges-launch.interupted");
|
2014-10-30 11:38:16 +00:00
|
|
|
|
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
|
|
|
|
/* remove signal handler */
|
2014-12-13 14:13:32 +00:00
|
|
|
return TRUE;
|
2014-10-30 11:38:16 +00:00
|
|
|
}
|
|
|
|
#endif /* G_OS_UNIX */
|
|
|
|
|
2010-09-24 18:31:53 +00:00
|
|
|
static gchar *
|
|
|
|
ensure_uri (gchar * location)
|
|
|
|
{
|
|
|
|
if (gst_uri_is_valid (location))
|
|
|
|
return g_strdup (location);
|
2012-05-02 07:44:25 +00:00
|
|
|
else
|
|
|
|
return gst_filename_to_uri (location, NULL);
|
2010-09-24 18:31:53 +00:00
|
|
|
}
|
|
|
|
|
2013-11-14 19:17:31 +00:00
|
|
|
static guint
|
|
|
|
get_flags_from_string (GType type, const gchar * str_flags)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
gint flags = 0;
|
|
|
|
GFlagsClass *class = g_type_class_ref (type);
|
|
|
|
|
|
|
|
for (i = 0; i < class->n_values; i++) {
|
|
|
|
if (g_strrstr (str_flags, class->values[i].value_nick)) {
|
|
|
|
flags |= class->values[i].value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_type_class_unref (class);
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2014-05-01 08:13:39 +00:00
|
|
|
|
|
|
|
|
2013-11-14 19:17:31 +00:00
|
|
|
static gboolean
|
|
|
|
parse_track_type (const gchar * option_name, const gchar * value,
|
|
|
|
gpointer udata, GError ** error)
|
|
|
|
{
|
|
|
|
track_types = get_flags_from_string (GES_TYPE_TRACK_TYPE, value);
|
|
|
|
|
|
|
|
if (track_types == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-01-12 16:52:10 +00:00
|
|
|
static gboolean
|
2010-07-15 17:50:22 +00:00
|
|
|
thumbnail_cb (gpointer pipeline)
|
|
|
|
{
|
|
|
|
static int i = 0;
|
2013-07-01 14:27:54 +00:00
|
|
|
GESPipeline *p = (GESPipeline *) pipeline;
|
2010-07-15 17:50:22 +00:00
|
|
|
gchar *filename;
|
2010-08-31 11:29:37 +00:00
|
|
|
gboolean res;
|
2010-07-15 17:50:22 +00:00
|
|
|
|
|
|
|
filename = g_strdup_printf ("thumbnail%d.jpg", i++);
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
res = ges_pipeline_save_thumbnail (p, -1, -1,
|
2013-04-17 19:51:30 +00:00
|
|
|
(gchar *) "image/jpeg", filename, NULL);
|
2010-08-31 11:29:37 +00:00
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
return res;
|
2010-07-15 17:50:22 +00:00
|
|
|
}
|
2010-05-24 08:59:43 +00:00
|
|
|
|
2013-09-12 21:34:55 +00:00
|
|
|
static void
|
|
|
|
error_loading_asset_cb (GESProject * project, GError * error,
|
|
|
|
const gchar * failed_id, GType extractable_type)
|
|
|
|
{
|
2013-10-11 20:05:03 +00:00
|
|
|
g_printerr ("Error loading asset %s: %s\n", failed_id, error->message);
|
2014-03-26 10:45:07 +00:00
|
|
|
seenerrors = TRUE;
|
2013-09-12 21:34:55 +00:00
|
|
|
|
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
}
|
|
|
|
|
2015-02-23 13:48:18 +00:00
|
|
|
static gboolean
|
|
|
|
_timeline_set_user_options (GESTimeline * timeline, const gchar * load_path)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
GESTrack *tracka, *trackv;
|
|
|
|
gboolean has_audio = FALSE, has_video = FALSE;
|
|
|
|
|
|
|
|
retry:
|
|
|
|
for (tmp = timeline->tracks; tmp; tmp = tmp->next) {
|
|
|
|
|
|
|
|
if (GES_TRACK (tmp->data)->type == GES_TRACK_TYPE_VIDEO)
|
|
|
|
has_video = TRUE;
|
|
|
|
else if (GES_TRACK (tmp->data)->type == GES_TRACK_TYPE_AUDIO)
|
|
|
|
has_audio = TRUE;
|
|
|
|
|
|
|
|
if (disable_mixing) {
|
|
|
|
GST_ERROR_OBJECT (tmp->data, "DISABLE MIXING");
|
|
|
|
ges_track_set_mixing (tmp->data, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(GES_TRACK (tmp->data)->type & track_types)) {
|
|
|
|
ges_timeline_remove_track (timeline, tmp->data);
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scenario && !load_path) {
|
|
|
|
if (!has_video && track_types & GES_TRACK_TYPE_VIDEO) {
|
|
|
|
trackv = GES_TRACK (ges_video_track_new ());
|
|
|
|
|
|
|
|
if (disable_mixing)
|
|
|
|
ges_track_set_mixing (trackv, FALSE);
|
|
|
|
|
|
|
|
if (!(ges_timeline_add_track (timeline, trackv)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_audio && track_types & GES_TRACK_TYPE_AUDIO) {
|
|
|
|
tracka = GES_TRACK (ges_audio_track_new ());
|
|
|
|
if (disable_mixing)
|
|
|
|
ges_track_set_mixing (tracka, FALSE);
|
|
|
|
|
|
|
|
if (!(ges_timeline_add_track (timeline, tracka)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-10-12 13:07:28 +00:00
|
|
|
static void
|
|
|
|
project_loaded_cb (GESProject * project, GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
GST_INFO ("Project loaded, playing it");
|
|
|
|
|
|
|
|
if (save_path) {
|
|
|
|
gchar *uri;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
if (g_strcmp0 (save_path, "+r") == 0) {
|
|
|
|
uri = ges_project_get_uri (project);
|
|
|
|
} else if (!(uri = ensure_uri (save_path))) {
|
|
|
|
g_error ("couldn't create uri for '%s", save_path);
|
|
|
|
|
|
|
|
seenerrors = TRUE;
|
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_print ("\nSaving project to %s\n", uri);
|
|
|
|
ges_project_save (project, timeline, uri, NULL, TRUE, &error);
|
|
|
|
g_free (uri);
|
|
|
|
|
|
|
|
g_assert_no_error (error);
|
|
|
|
if (error) {
|
|
|
|
seenerrors = TRUE;
|
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-23 13:48:18 +00:00
|
|
|
_timeline_set_user_options (timeline, ges_project_get_uri (project));
|
|
|
|
|
|
|
|
if (ges_project_get_uri (project)
|
|
|
|
&& ges_validate_activate (GST_PIPELINE (pipeline), scenario,
|
2014-10-31 10:56:16 +00:00
|
|
|
&needs_set_state) == FALSE) {
|
|
|
|
g_error ("Could not activate scenario %s", scenario);
|
|
|
|
seenerrors = TRUE;
|
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
}
|
|
|
|
|
2014-07-27 13:42:42 +00:00
|
|
|
if (needs_set_state && gst_element_set_state (GST_ELEMENT (pipeline),
|
2013-10-12 13:07:28 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
|
|
|
|
g_error ("Failed to start the pipeline\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-19 17:28:41 +00:00
|
|
|
|
2011-01-12 16:52:10 +00:00
|
|
|
static gboolean
|
2015-02-23 13:48:18 +00:00
|
|
|
_save_timeline (GESTimeline * timeline, const gchar * load_path)
|
2010-06-03 17:14:41 +00:00
|
|
|
{
|
2015-02-23 13:48:18 +00:00
|
|
|
if (save_path && !load_path) {
|
|
|
|
gchar *uri;
|
|
|
|
if (!(uri = ensure_uri (save_path))) {
|
|
|
|
g_error ("couldn't create uri for '%s", save_path);
|
|
|
|
return FALSE;
|
2015-02-19 17:28:41 +00:00
|
|
|
}
|
|
|
|
|
2015-02-23 13:48:18 +00:00
|
|
|
return ges_timeline_save_to_uri (timeline, uri, NULL, TRUE, NULL);
|
2010-06-03 17:14:41 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 17:28:41 +00:00
|
|
|
return TRUE;
|
2010-06-03 17:14:41 +00:00
|
|
|
}
|
|
|
|
|
2010-09-24 18:31:53 +00:00
|
|
|
static GESTimeline *
|
2015-02-23 13:48:18 +00:00
|
|
|
create_timeline (const gchar * serialized_timeline, const gchar * proj_uri,
|
2014-05-08 15:21:33 +00:00
|
|
|
const gchar * scenario)
|
2010-04-20 11:08:27 +00:00
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2015-02-23 13:48:18 +00:00
|
|
|
GESProject *project;
|
2010-04-20 11:08:27 +00:00
|
|
|
|
2015-02-23 16:41:59 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
|
2013-10-12 13:07:28 +00:00
|
|
|
if (proj_uri != NULL) {
|
2015-02-23 13:48:18 +00:00
|
|
|
project = ges_project_new (proj_uri);
|
|
|
|
} else if (scenario == NULL) {
|
|
|
|
project = ges_project_new (serialized_timeline);
|
|
|
|
} else {
|
|
|
|
project = ges_project_new (NULL);
|
2014-09-26 15:51:14 +00:00
|
|
|
}
|
|
|
|
|
2015-02-23 13:48:18 +00:00
|
|
|
g_signal_connect (project, "error-loading-asset",
|
|
|
|
G_CALLBACK (error_loading_asset_cb), NULL);
|
|
|
|
g_signal_connect (project, "loaded", G_CALLBACK (project_loaded_cb), NULL);
|
2010-06-16 11:22:15 +00:00
|
|
|
|
2015-02-23 16:41:59 +00:00
|
|
|
timeline = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), &error));
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
g_error ("Could not create timeline, error: %s", error->message);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-04-20 11:08:27 +00:00
|
|
|
|
2010-09-24 18:31:53 +00:00
|
|
|
return timeline;
|
2014-09-25 12:55:15 +00:00
|
|
|
}
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
static GESPipeline *
|
2013-08-31 00:03:16 +00:00
|
|
|
create_pipeline (GESTimeline ** ret_timeline, gchar * load_path,
|
2015-02-23 13:48:18 +00:00
|
|
|
const gchar * serialized_timeline, const gchar * scenario)
|
2010-09-24 18:31:53 +00:00
|
|
|
{
|
2013-09-12 21:34:55 +00:00
|
|
|
gchar *uri = NULL;
|
2011-01-17 15:46:15 +00:00
|
|
|
GESTimeline *timeline = NULL;
|
2010-09-24 18:31:53 +00:00
|
|
|
|
2011-01-17 15:46:15 +00:00
|
|
|
/* Timeline creation */
|
2010-09-24 18:31:53 +00:00
|
|
|
if (load_path) {
|
2011-01-17 15:46:15 +00:00
|
|
|
g_printf ("Loading project from : %s\n", load_path);
|
2010-09-24 18:31:53 +00:00
|
|
|
|
|
|
|
if (!(uri = ensure_uri (load_path))) {
|
2011-01-17 15:46:15 +00:00
|
|
|
g_error ("couldn't create uri for '%s'", load_path);
|
|
|
|
goto failure;
|
2010-09-24 18:31:53 +00:00
|
|
|
}
|
2013-03-30 12:37:43 +00:00
|
|
|
}
|
2014-05-06 13:32:18 +00:00
|
|
|
|
|
|
|
pipeline = ges_pipeline_new ();
|
|
|
|
|
2015-02-23 13:48:18 +00:00
|
|
|
if (!(timeline = create_timeline (serialized_timeline, uri, scenario))) {
|
|
|
|
GST_ERROR ("Could not create the timeline");
|
2013-09-12 21:34:55 +00:00
|
|
|
goto failure;
|
2015-02-23 13:48:18 +00:00
|
|
|
}
|
2013-09-12 21:34:55 +00:00
|
|
|
|
2014-07-28 13:26:18 +00:00
|
|
|
if (!load_path)
|
|
|
|
ges_timeline_commit (timeline);
|
2010-09-24 18:31:53 +00:00
|
|
|
|
2011-01-17 15:46:15 +00:00
|
|
|
/* save project if path is given. we do this now in case GES crashes or
|
|
|
|
* hangs during playback. */
|
2014-09-25 12:55:15 +00:00
|
|
|
if (!_save_timeline (timeline, load_path))
|
|
|
|
goto failure;
|
2010-09-24 18:31:53 +00:00
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
/* In order to view our timeline, let's grab a convenience pipeline to put
|
|
|
|
* our timeline in. */
|
|
|
|
|
2013-09-19 23:31:10 +00:00
|
|
|
if (mute) {
|
|
|
|
GstElement *sink = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
|
|
|
|
g_object_set (sink, "sync", TRUE, NULL);
|
|
|
|
ges_pipeline_preview_set_audio_sink (pipeline, sink);
|
|
|
|
|
|
|
|
sink = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
g_object_set (sink, "sync", TRUE, NULL);
|
|
|
|
ges_pipeline_preview_set_video_sink (pipeline, sink);
|
|
|
|
}
|
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
/* Add the timeline to that pipeline */
|
2014-02-04 09:45:58 +00:00
|
|
|
if (!ges_pipeline_set_timeline (pipeline, timeline))
|
2011-01-17 15:46:15 +00:00
|
|
|
goto failure;
|
2010-04-20 11:08:27 +00:00
|
|
|
|
2013-08-31 00:03:16 +00:00
|
|
|
*ret_timeline = timeline;
|
2014-05-10 20:52:18 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (uri)
|
|
|
|
g_free (uri);
|
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
return pipeline;
|
2011-01-17 15:46:15 +00:00
|
|
|
|
|
|
|
failure:
|
|
|
|
{
|
|
|
|
if (timeline)
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2011-01-17 15:46:15 +00:00
|
|
|
if (pipeline)
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (pipeline);
|
2014-05-10 20:52:18 +00:00
|
|
|
pipeline = NULL;
|
|
|
|
timeline = NULL;
|
|
|
|
|
|
|
|
goto done;
|
2011-01-17 15:46:15 +00:00
|
|
|
}
|
2010-04-20 11:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bus_message_cb (GstBus * bus, GstMessage * message, GMainLoop * mainloop)
|
|
|
|
{
|
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
2013-11-09 12:51:55 +00:00
|
|
|
case GST_MESSAGE_WARNING:{
|
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, "ges-launch.warning");
|
|
|
|
break;
|
|
|
|
}
|
2011-05-05 18:02:28 +00:00
|
|
|
case GST_MESSAGE_ERROR:{
|
|
|
|
GError *err = NULL;
|
|
|
|
gchar *dbg_info = NULL;
|
|
|
|
|
|
|
|
gst_message_parse_error (message, &err, &dbg_info);
|
2013-08-31 00:03:16 +00:00
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, "ges-launch-error");
|
|
|
|
g_printerr ("ERROR from element %s: %s\n", GST_OBJECT_NAME (message->src),
|
|
|
|
err->message);
|
2011-05-05 18:02:28 +00:00
|
|
|
g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
|
|
|
|
g_error_free (err);
|
|
|
|
g_free (dbg_info);
|
2010-09-16 07:07:05 +00:00
|
|
|
seenerrors = TRUE;
|
2010-04-20 11:08:27 +00:00
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
break;
|
2011-05-05 18:02:28 +00:00
|
|
|
}
|
2010-04-20 11:08:27 +00:00
|
|
|
case GST_MESSAGE_EOS:
|
2010-06-02 09:49:08 +00:00
|
|
|
if (repeat > 0) {
|
2010-11-11 16:39:32 +00:00
|
|
|
g_printerr ("Looping again\n");
|
|
|
|
if (!gst_element_seek_simple (GST_ELEMENT (pipeline), GST_FORMAT_TIME,
|
|
|
|
GST_SEEK_FLAG_FLUSH, 0))
|
|
|
|
g_printerr ("seeking failed\n");
|
|
|
|
else
|
|
|
|
g_printerr ("seeking succeeded\n");
|
2010-06-02 09:49:08 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
2010-11-11 16:39:32 +00:00
|
|
|
g_printerr ("Looping set\n");
|
2010-06-02 09:49:08 +00:00
|
|
|
repeat -= 1;
|
|
|
|
} else {
|
2013-09-13 21:15:21 +00:00
|
|
|
g_printerr ("\nDone\n");
|
2010-06-02 09:49:08 +00:00
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
}
|
2010-04-20 11:08:27 +00:00
|
|
|
break;
|
2013-11-09 12:51:55 +00:00
|
|
|
case GST_MESSAGE_STATE_CHANGED:
|
|
|
|
if (GST_MESSAGE_SRC (message) == GST_OBJECT_CAST (pipeline)) {
|
|
|
|
gchar *dump_name;
|
|
|
|
GstState old, new, pending;
|
|
|
|
gchar *state_transition_name;
|
|
|
|
|
|
|
|
gst_message_parse_state_changed (message, &old, &new, &pending);
|
|
|
|
state_transition_name = g_strdup_printf ("%s_%s",
|
|
|
|
gst_element_state_get_name (old), gst_element_state_get_name (new));
|
|
|
|
dump_name = g_strconcat ("ges-launch.", state_transition_name, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, dump_name);
|
|
|
|
|
|
|
|
g_free (dump_name);
|
|
|
|
g_free (state_transition_name);
|
|
|
|
}
|
|
|
|
break;
|
2014-05-18 16:34:26 +00:00
|
|
|
case GST_MESSAGE_REQUEST_STATE:
|
|
|
|
ges_validate_handle_request_state_change (message, mainloop);
|
|
|
|
break;
|
2010-04-20 11:08:27 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-12 16:45:23 +00:00
|
|
|
static void
|
|
|
|
print_enum (GType enum_type)
|
2010-06-03 17:13:42 +00:00
|
|
|
{
|
2011-01-12 16:45:23 +00:00
|
|
|
GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (enum_type));
|
|
|
|
guint i;
|
2010-06-03 17:13:42 +00:00
|
|
|
|
2011-01-12 16:45:23 +00:00
|
|
|
for (i = 0; i < enum_class->n_values; i++) {
|
2011-01-17 15:46:15 +00:00
|
|
|
g_printf ("%s\n", enum_class->values[i].value_nick);
|
2010-06-03 17:13:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-12 16:45:23 +00:00
|
|
|
g_type_class_unref (enum_class);
|
2010-06-03 17:13:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-12 16:45:23 +00:00
|
|
|
static void
|
|
|
|
print_transition_list (void)
|
2010-06-03 17:13:42 +00:00
|
|
|
{
|
2011-01-12 16:45:23 +00:00
|
|
|
print_enum (GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE);
|
|
|
|
}
|
2010-06-11 13:28:43 +00:00
|
|
|
|
2011-01-12 16:45:23 +00:00
|
|
|
static void
|
|
|
|
print_pattern_list (void)
|
|
|
|
{
|
|
|
|
print_enum (GES_VIDEO_TEST_PATTERN_TYPE);
|
2010-06-03 17:13:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-31 00:32:56 +00:00
|
|
|
static GstEncodingProfile *
|
|
|
|
_parse_encoding_profile (const gchar * format)
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
2014-06-05 00:16:01 +00:00
|
|
|
GstEncodingProfile *encoding_profile = NULL;
|
2013-08-31 00:32:56 +00:00
|
|
|
gchar **restriction_format, **preset_v;
|
|
|
|
|
2014-06-05 00:16:01 +00:00
|
|
|
guint i = 1, presence = 0;
|
2013-08-31 00:32:56 +00:00
|
|
|
GstCaps *restrictioncaps = NULL;
|
|
|
|
gchar **strpresence_v, **strcaps_v = g_strsplit (format, ":", 0);
|
|
|
|
|
|
|
|
if (strcaps_v[0] && *strcaps_v[0]) {
|
2014-06-05 00:16:01 +00:00
|
|
|
if (strcaps_v[1] == NULL) {
|
|
|
|
/* Only 1 profile which means no container used */
|
|
|
|
i = 0;
|
|
|
|
} else {
|
|
|
|
caps = gst_caps_from_string (strcaps_v[0]);
|
|
|
|
if (caps == NULL) {
|
|
|
|
g_printerr ("Could not parse caps %s", strcaps_v[0]);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
encoding_profile =
|
|
|
|
GST_ENCODING_PROFILE (gst_encoding_container_profile_new
|
|
|
|
("User profile", "User profile", caps, NULL));
|
|
|
|
gst_caps_unref (caps);
|
2013-08-31 00:32:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-05 00:16:01 +00:00
|
|
|
for (; strcaps_v[i]; i++) {
|
2013-08-31 00:32:56 +00:00
|
|
|
gchar *strcaps, *strpresence;
|
2014-05-10 20:52:18 +00:00
|
|
|
char *preset_name = NULL;
|
|
|
|
GstEncodingProfile *profile = NULL;
|
2013-08-31 00:32:56 +00:00
|
|
|
|
|
|
|
restriction_format = g_strsplit (strcaps_v[i], "->", 0);
|
|
|
|
if (restriction_format[1]) {
|
|
|
|
restrictioncaps = gst_caps_from_string (restriction_format[0]);
|
|
|
|
strcaps = g_strdup (restriction_format[1]);
|
|
|
|
} else {
|
|
|
|
restrictioncaps = NULL;
|
|
|
|
strcaps = g_strdup (restriction_format[0]);
|
|
|
|
}
|
|
|
|
g_strfreev (restriction_format);
|
|
|
|
|
|
|
|
preset_v = g_strsplit (strcaps, "+", 0);
|
|
|
|
if (preset_v[1]) {
|
|
|
|
strpresence = preset_v[1];
|
|
|
|
g_free (strcaps);
|
|
|
|
strcaps = g_strdup (preset_v[0]);
|
|
|
|
} else {
|
|
|
|
strpresence = preset_v[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
strpresence_v = g_strsplit (strpresence, "|", 0);
|
|
|
|
if (strpresence_v[1]) { /* We have a presence */
|
|
|
|
gchar *endptr;
|
|
|
|
|
|
|
|
if (preset_v[1]) { /* We have preset and presence */
|
|
|
|
preset_name = g_strdup (strpresence_v[0]);
|
|
|
|
} else { /* We have a presence but no preset */
|
|
|
|
g_free (strcaps);
|
|
|
|
strcaps = g_strdup (strpresence_v[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
presence = strtoll (strpresence_v[1], &endptr, 10);
|
|
|
|
if (endptr == strpresence_v[1]) {
|
|
|
|
g_printerr ("Wrong presence %s\n", strpresence_v[1]);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else { /* We have no presence */
|
|
|
|
if (preset_v[1]) { /* Not presence but preset */
|
|
|
|
preset_name = g_strdup (preset_v[1]);
|
|
|
|
g_free (strcaps);
|
|
|
|
strcaps = g_strdup (preset_v[0]);
|
|
|
|
} /* Else we have no presence nor preset */
|
|
|
|
}
|
|
|
|
g_strfreev (strpresence_v);
|
|
|
|
g_strfreev (preset_v);
|
|
|
|
|
|
|
|
GST_DEBUG ("Creating preset with restrictions: %" GST_PTR_FORMAT
|
|
|
|
", caps: %s, preset %s, presence %d", restrictioncaps, strcaps,
|
|
|
|
preset_name ? preset_name : "none", presence);
|
|
|
|
|
|
|
|
caps = gst_caps_from_string (strcaps);
|
|
|
|
g_free (strcaps);
|
|
|
|
if (caps == NULL) {
|
|
|
|
g_warning ("Could not create caps for %s", strcaps_v[i]);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_str_has_prefix (strcaps_v[i], "audio/")) {
|
|
|
|
profile = GST_ENCODING_PROFILE (gst_encoding_audio_profile_new (caps,
|
|
|
|
preset_name, restrictioncaps, presence));
|
|
|
|
} else if (g_str_has_prefix (strcaps_v[i], "video/") ||
|
|
|
|
g_str_has_prefix (strcaps_v[i], "image/")) {
|
|
|
|
profile = GST_ENCODING_PROFILE (gst_encoding_video_profile_new (caps,
|
|
|
|
preset_name, restrictioncaps, presence));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (preset_name);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
if (restrictioncaps)
|
|
|
|
gst_caps_unref (restrictioncaps);
|
|
|
|
|
|
|
|
if (profile == NULL) {
|
|
|
|
g_warning ("No way to create a preset for caps: %s", strcaps_v[i]);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (encoding_profile) {
|
|
|
|
if (gst_encoding_container_profile_add_profile
|
|
|
|
(GST_ENCODING_CONTAINER_PROFILE (encoding_profile),
|
|
|
|
profile) == FALSE) {
|
|
|
|
g_warning ("Can not create a preset for caps: %s", strcaps_v[i]);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
encoding_profile = profile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_strfreev (strcaps_v);
|
|
|
|
|
|
|
|
return encoding_profile;
|
|
|
|
}
|
|
|
|
|
2014-11-03 11:18:35 +00:00
|
|
|
static gboolean
|
|
|
|
_add_media_path (const gchar * option_name, const gchar * value,
|
|
|
|
gpointer udata, GError ** error)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (gst_uri_is_valid (value), FALSE);
|
|
|
|
|
|
|
|
if (g_strcmp0 (option_name, "--sample-path-recurse") == 0 ||
|
|
|
|
g_strcmp0 (option_name, "-R") == 0) {
|
|
|
|
ges_add_missing_uri_relocation_uri (value, TRUE);
|
|
|
|
} else {
|
|
|
|
GST_INFO ("Adding folder: %s", value);
|
|
|
|
ges_add_missing_uri_relocation_uri (value, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-02-19 07:51:20 +00:00
|
|
|
/* g_free after usage */
|
|
|
|
static gchar *
|
|
|
|
sanitize_argument (gchar * arg)
|
|
|
|
{
|
|
|
|
char *equal_index = strstr (arg, "=");
|
|
|
|
char *space_index = strstr (arg, " ");
|
|
|
|
gchar *new_string = g_malloc (sizeof (gchar) * (strlen (arg) + 3));
|
|
|
|
gchar *tmp_string = new_string;
|
|
|
|
|
|
|
|
if (!space_index)
|
|
|
|
return g_strdup (arg);
|
|
|
|
|
|
|
|
if (!equal_index || equal_index > space_index)
|
|
|
|
return g_strdup_printf ("\"%s\"", arg);
|
|
|
|
|
|
|
|
for (arg = arg; *arg != '\0'; arg++) {
|
|
|
|
*tmp_string = *arg;
|
|
|
|
tmp_string += 1;
|
|
|
|
if (*arg == '=') {
|
|
|
|
*tmp_string = '"';
|
|
|
|
tmp_string += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*tmp_string = '"';
|
|
|
|
tmp_string += 1;
|
|
|
|
*tmp_string = '\0';
|
|
|
|
|
|
|
|
return new_string;
|
|
|
|
}
|
|
|
|
|
2015-02-23 13:48:18 +00:00
|
|
|
static gchar *
|
2015-02-19 07:51:20 +00:00
|
|
|
_parse_timeline (int argc, char **argv)
|
|
|
|
{
|
|
|
|
gint i;
|
2015-02-23 13:48:18 +00:00
|
|
|
|
2015-02-19 07:51:20 +00:00
|
|
|
gchar *string = g_strdup (" ");
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
gchar *new_string;
|
|
|
|
gchar *sanitized = sanitize_argument (argv[i]);
|
|
|
|
|
|
|
|
new_string = g_strconcat (string, " ", sanitized, NULL);
|
|
|
|
|
|
|
|
g_free (sanitized);
|
|
|
|
g_free (string);
|
|
|
|
string = new_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-23 13:48:18 +00:00
|
|
|
return string;
|
2015-02-19 07:51:20 +00:00
|
|
|
}
|
|
|
|
|
2015-02-26 12:19:25 +00:00
|
|
|
static void
|
|
|
|
_print_all_commands (void)
|
|
|
|
{
|
|
|
|
/* Yeah I know very fancy */
|
|
|
|
g_print ("Available ges-launch-1.0 commands:\n\n");
|
|
|
|
g_print (" %-9s %-11s %-10s\n\n", "+clip", "+effect", "set-");
|
|
|
|
g_print ("See ges-launch-1.0 help <command> or ges-launch-1.0 help <guide> "
|
|
|
|
"to read about a specific command or a given guide\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_check_command_help (int argc, gchar ** argv)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* gchar *page = NULL;
|
|
|
|
*
|
|
|
|
* if (argc == 2)
|
|
|
|
* page = g_strdup ("ges-launch-1.0");
|
|
|
|
* else if (!g_strcmp0 (argv[2], "all"))
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!g_strcmp0 (argv[1], "help")) {
|
|
|
|
_print_all_commands ();
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* else
|
|
|
|
* page = g_strconcat ("ges-launch-1.0", "-", argv[2], NULL);
|
|
|
|
*
|
|
|
|
* if (page) {
|
|
|
|
* execlp ("man", "man", page, NULL);
|
|
|
|
* g_free (page);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* an error is raised by execlp it will be displayed in the terminal
|
|
|
|
* exit (0);
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
int
|
|
|
|
main (int argc, gchar ** argv)
|
|
|
|
{
|
2013-10-12 13:07:28 +00:00
|
|
|
gint validate_res;
|
2010-04-20 11:08:27 +00:00
|
|
|
GError *err = NULL;
|
2015-02-23 13:48:18 +00:00
|
|
|
gchar *outputuri = NULL, *serialized_timeline = NULL;
|
2013-08-31 00:32:56 +00:00
|
|
|
const gchar *format = NULL;
|
2011-11-30 14:44:45 +00:00
|
|
|
gchar *exclude_args = NULL;
|
2010-04-20 11:08:27 +00:00
|
|
|
static gboolean smartrender = FALSE;
|
2010-06-03 17:13:42 +00:00
|
|
|
static gboolean list_transitions = FALSE;
|
|
|
|
static gboolean list_patterns = FALSE;
|
2010-07-15 17:50:22 +00:00
|
|
|
static gdouble thumbinterval = 0;
|
2011-11-30 14:44:45 +00:00
|
|
|
static gboolean verbose = FALSE;
|
2010-09-24 18:31:53 +00:00
|
|
|
gchar *load_path = NULL;
|
2014-05-08 15:21:33 +00:00
|
|
|
gchar *videosink = NULL, *audiosink = NULL;
|
2014-10-12 17:46:59 +00:00
|
|
|
gboolean inspect_action_type = FALSE;
|
2014-07-20 09:47:18 +00:00
|
|
|
gchar *encoding_profile = NULL;
|
2014-05-08 12:12:11 +00:00
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
GOptionEntry options[] = {
|
|
|
|
{"outputuri", 'o', 0, G_OPTION_ARG_STRING, &outputuri,
|
2014-07-20 09:47:56 +00:00
|
|
|
"URI to encode to", "<protocol>://<location>"},
|
2013-08-31 00:32:56 +00:00
|
|
|
{"format", 'f', 0, G_OPTION_ARG_STRING, &format,
|
2014-07-20 09:47:56 +00:00
|
|
|
"Specify an encoding profile on the command line",
|
|
|
|
"<profile>"},
|
2014-07-20 09:47:18 +00:00
|
|
|
{"encoding-profile", 'e', 0, G_OPTION_ARG_STRING, &encoding_profile,
|
|
|
|
"Use a specific encoding profile from XML", "<profile-name>"},
|
2013-08-31 00:03:16 +00:00
|
|
|
{"repeat", 'r', 0, G_OPTION_ARG_INT, &repeat,
|
2014-07-20 09:47:56 +00:00
|
|
|
"Number of times to repeat timeline", "<times>"},
|
2015-02-26 12:49:23 +00:00
|
|
|
{"list-transitions", 0, 0, G_OPTION_ARG_NONE, &list_transitions,
|
2010-06-03 17:13:42 +00:00
|
|
|
"List valid transition types and exit", NULL},
|
2015-02-26 12:49:23 +00:00
|
|
|
{"save", 's', 0, G_OPTION_ARG_STRING, &save_path,
|
2010-09-24 18:31:53 +00:00
|
|
|
"Save project to file before rendering", "<path>"},
|
2013-08-31 00:03:16 +00:00
|
|
|
{"load", 'l', 0, G_OPTION_ARG_STRING, &load_path,
|
2010-09-24 18:31:53 +00:00
|
|
|
"Load project from file before rendering", "<path>"},
|
2015-02-26 12:49:23 +00:00
|
|
|
{"track-types", 't', 0, G_OPTION_ARG_CALLBACK, &parse_track_type,
|
2013-11-14 19:17:31 +00:00
|
|
|
"Defines the track types to be created"},
|
2015-02-26 12:49:23 +00:00
|
|
|
{"mute", 'm', 0, G_OPTION_ARG_NONE, &mute,
|
2014-07-20 09:47:56 +00:00
|
|
|
"Mute playback output by using fakesinks"},
|
2014-04-30 18:58:42 +00:00
|
|
|
{"disable-mixing", 0, 0, G_OPTION_ARG_NONE, &disable_mixing,
|
|
|
|
"Do not use mixing element in the tracks"},
|
2014-05-08 12:12:11 +00:00
|
|
|
{"videosink", 'v', 0, G_OPTION_ARG_STRING, &videosink,
|
2014-05-08 15:21:33 +00:00
|
|
|
"The video sink used for playing back", "<videosink>"},
|
|
|
|
{"audiosink", 'a', 0, G_OPTION_ARG_STRING, &audiosink,
|
|
|
|
"The audio sink used for playing back", "<audiosink>"},
|
2015-02-26 12:49:23 +00:00
|
|
|
{"sample-paths", 'p', 0, G_OPTION_ARG_CALLBACK, &_add_media_path,
|
2014-11-03 11:18:35 +00:00
|
|
|
"List of pathes to look assets in if they were moved"},
|
|
|
|
{"sample-path-recurse", 'R', 0, G_OPTION_ARG_CALLBACK,
|
|
|
|
&_add_media_path,
|
|
|
|
"Same as above, but recursing into the folder"},
|
2014-04-26 07:51:37 +00:00
|
|
|
#ifdef HAVE_GST_VALIDATE
|
2015-02-26 12:49:23 +00:00
|
|
|
{"inspect-action-type", 0, 0, G_OPTION_ARG_NONE, &inspect_action_type,
|
2014-10-12 17:46:59 +00:00
|
|
|
"Inspect the avalaible action types with which to write scenarios"
|
|
|
|
" if no parameter passed, it will list all avalaible action types"
|
|
|
|
" otherwize will print the full description of the wanted types",
|
|
|
|
NULL},
|
2013-09-13 21:15:21 +00:00
|
|
|
{"set-scenario", 0, 0, G_OPTION_ARG_STRING, &scenario,
|
|
|
|
"Specify a GstValidate scenario to run, 'none' means load gst-validate"
|
|
|
|
" but run no scenario on it", "<scenario_name>"},
|
2014-04-26 07:51:37 +00:00
|
|
|
#endif
|
2010-04-20 11:08:27 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
2013-09-13 21:15:21 +00:00
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
GOptionContext *ctx;
|
|
|
|
GstBus *bus;
|
|
|
|
|
2014-10-30 11:38:16 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
guint signal_watch_id;
|
|
|
|
#endif
|
|
|
|
|
2015-02-26 12:19:25 +00:00
|
|
|
_check_command_help (argc, argv);
|
2013-06-17 05:55:54 +00:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2011-01-26 21:50:00 +00:00
|
|
|
ctx = g_option_context_new ("- plays or renders a timeline.");
|
2010-04-20 11:08:27 +00:00
|
|
|
g_option_context_set_summary (ctx,
|
2011-08-01 11:42:17 +00:00
|
|
|
"ges-launch renders a timeline, which can be specified on the commandline,\n"
|
2014-07-20 09:47:56 +00:00
|
|
|
"or loaded from a xges file using the -l option.\n\n"
|
2011-08-01 11:42:17 +00:00
|
|
|
"A timeline is a list of files, patterns, and transitions to be rendered\n"
|
|
|
|
"one after the other. Files and Patterns provide video and audio as the\n"
|
|
|
|
"primary input, and transitions animate between the end of one file/pattern\n"
|
|
|
|
"and the beginning of a new one. Hence, transitions can only be listed\n"
|
|
|
|
"in between patterns or files.\n\n"
|
|
|
|
"A file is a triplet of filename, inpoint (in seconds) and\n"
|
|
|
|
"duration (in seconds). If the duration is 0, the full file length is used.\n\n"
|
|
|
|
"Patterns and transitions are triplets that begin with either \"+pattern\"\n"
|
|
|
|
"or \"+transition\", followed by a <type> and duration (in seconds, must be\n"
|
|
|
|
"greater than 0)\n\n"
|
|
|
|
"Durations in all cases can be fractions of a second.\n\n"
|
2014-07-20 09:47:56 +00:00
|
|
|
"========\nExamples\n========\n\n"
|
|
|
|
"Play video1.ogv from inpoint 5 with duration 10 in seconds:\n"
|
|
|
|
"$ ges-launch video1.ogv 5 10\n\n"
|
|
|
|
"Crossfade:\n"
|
|
|
|
"$ ges-launch video1.ogv 0 10 +transition crossfade 3.5 video2.ogv 0 10\n\n"
|
|
|
|
"Render xges to ogv:\n"
|
|
|
|
"$ ges-launch -l project.xges -o rendering.ogv\n\n"
|
|
|
|
"Render xges to an XML encoding-profile called mymkv:\n"
|
|
|
|
"$ ges-launch -l project.xges -o rendering.mkv -e mymkv\n\n"
|
|
|
|
"Render to mp4:\n"
|
|
|
|
"$ ges-launch -l project.xges -o out.mp4 \\\n"
|
|
|
|
" -f \"video/quicktime,variant=iso:video/x-h264:audio/mpeg,mpegversion=1,layer=3\"\n\n"
|
|
|
|
"Render xges to WebM with 1920x1080 resolution:\n"
|
|
|
|
"$ ges-launch -l project.xges -o out.webm \\\n"
|
|
|
|
" -f \"video/webm:video/x-raw,width=1920,height=1080->video/x-vp8:audio/x-vorbis\"\n\n"
|
|
|
|
"A preset name can be used by adding +presetname:\n"
|
|
|
|
"$ ges-launch -l project.xges -o out.webm \\\n"
|
|
|
|
" -f \"video/webm:video/x-vp8+presetname:x-vorbis\"\n\n"
|
|
|
|
"The presence property of the profile can be specified with |<presence>:\n"
|
|
|
|
"$ ges-launch -l project.xges -o out.ogv \\\n"
|
|
|
|
" -f \"application/ogg:video/x-theora|<presence>:audio/x-vorbis\"");
|
2010-04-20 11:08:27 +00:00
|
|
|
g_option_context_add_main_entries (ctx, options, NULL);
|
|
|
|
g_option_context_add_group (ctx, gst_init_get_option_group ());
|
2014-11-03 10:51:51 +00:00
|
|
|
g_option_context_add_group (ctx, ges_init_get_option_group ());
|
2010-04-20 11:08:27 +00:00
|
|
|
|
2015-02-19 07:51:20 +00:00
|
|
|
g_option_context_set_ignore_unknown_options (ctx, TRUE);
|
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
|
2010-11-11 16:39:32 +00:00
|
|
|
g_printerr ("Error initializing: %s\n", err->message);
|
2010-04-20 11:08:27 +00:00
|
|
|
g_option_context_free (ctx);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2011-01-12 16:45:23 +00:00
|
|
|
/* Initialize the GStreamer Editing Services */
|
2011-02-07 12:19:18 +00:00
|
|
|
if (!ges_init ()) {
|
|
|
|
g_printerr ("Error initializing GES\n");
|
2013-10-12 13:07:28 +00:00
|
|
|
|
2011-02-07 12:19:18 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
2011-01-12 16:45:23 +00:00
|
|
|
|
2010-06-03 17:13:42 +00:00
|
|
|
if (list_transitions) {
|
|
|
|
print_transition_list ();
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (list_patterns) {
|
|
|
|
print_pattern_list ();
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
2014-10-12 17:46:59 +00:00
|
|
|
if (inspect_action_type)
|
2014-09-05 19:08:49 +00:00
|
|
|
return ges_validate_print_action_types ((const gchar **) argv + 1,
|
|
|
|
argc - 1);
|
2014-08-22 19:01:07 +00:00
|
|
|
|
2015-02-19 17:28:41 +00:00
|
|
|
if (((!load_path && !scenario && (argc < 1)))) {
|
2011-01-17 15:46:15 +00:00
|
|
|
g_printf ("%s", g_option_context_get_help (ctx, TRUE, NULL));
|
2010-04-20 11:08:27 +00:00
|
|
|
g_option_context_free (ctx);
|
2010-09-16 07:07:05 +00:00
|
|
|
exit (1);
|
2010-04-20 11:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_option_context_free (ctx);
|
|
|
|
|
|
|
|
/* Create the pipeline */
|
2015-02-23 13:48:18 +00:00
|
|
|
serialized_timeline = _parse_timeline (argc, argv);
|
|
|
|
create_pipeline (&timeline, load_path, serialized_timeline, scenario);
|
2010-04-20 11:08:27 +00:00
|
|
|
if (!pipeline)
|
2010-09-16 07:07:05 +00:00
|
|
|
exit (1);
|
2010-04-20 11:08:27 +00:00
|
|
|
|
2014-05-08 12:12:11 +00:00
|
|
|
if (videosink != NULL) {
|
2014-05-08 15:21:33 +00:00
|
|
|
GError *err = NULL;
|
|
|
|
GstElement *sink = gst_parse_bin_from_description (videosink, TRUE, &err);
|
2014-05-08 12:12:11 +00:00
|
|
|
if (sink == NULL) {
|
2014-05-08 15:21:33 +00:00
|
|
|
GST_ERROR ("could not create the requested videosink %s (err: %s), "
|
|
|
|
"exiting", err ? err->message : "", videosink);
|
2014-05-08 12:12:11 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
ges_pipeline_preview_set_video_sink (pipeline, sink);
|
|
|
|
}
|
|
|
|
|
2014-05-08 15:21:33 +00:00
|
|
|
if (audiosink != NULL) {
|
|
|
|
GError *err = NULL;
|
|
|
|
GstElement *sink = gst_parse_bin_from_description (audiosink, TRUE, &err);
|
|
|
|
if (sink == NULL) {
|
|
|
|
GST_ERROR ("could not create the requested audiosink %s (err: %s), "
|
|
|
|
"exiting", err ? err->message : "", audiosink);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
ges_pipeline_preview_set_audio_sink (pipeline, sink);
|
|
|
|
}
|
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
/* Setup profile/encoding if needed */
|
2013-08-31 00:03:16 +00:00
|
|
|
if (smartrender || outputuri) {
|
|
|
|
GstEncodingProfile *prof = NULL;
|
|
|
|
|
2013-08-31 00:32:56 +00:00
|
|
|
if (!format) {
|
|
|
|
GESProject *proj =
|
|
|
|
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)));
|
2013-08-31 00:03:16 +00:00
|
|
|
const GList *profiles = ges_project_list_encoding_profiles (proj);
|
2010-06-21 09:47:21 +00:00
|
|
|
|
2014-07-20 09:47:18 +00:00
|
|
|
if (profiles) {
|
|
|
|
prof = profiles->data;
|
|
|
|
if (encoding_profile)
|
|
|
|
for (; profiles; profiles = profiles->next)
|
|
|
|
if (strcmp (encoding_profile,
|
|
|
|
gst_encoding_profile_get_name (profiles->data)) == 0)
|
|
|
|
prof = profiles->data;
|
|
|
|
}
|
2013-08-31 00:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!prof) {
|
2013-08-31 00:32:56 +00:00
|
|
|
if (format == NULL)
|
|
|
|
format = "application/ogg:video/x-theora:audio/x-vorbis";
|
|
|
|
|
|
|
|
prof = _parse_encoding_profile (format);
|
2013-08-31 00:03:16 +00:00
|
|
|
}
|
2010-04-20 11:08:27 +00:00
|
|
|
|
2013-09-13 23:38:43 +00:00
|
|
|
if (outputuri)
|
|
|
|
outputuri = ensure_uri (outputuri);
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
if (!prof || !ges_pipeline_set_render_settings (pipeline, outputuri, prof)
|
|
|
|
|| !ges_pipeline_set_mode (pipeline,
|
2014-02-17 11:34:04 +00:00
|
|
|
smartrender ? GES_PIPELINE_MODE_SMART_RENDER :
|
|
|
|
GES_PIPELINE_MODE_RENDER)) {
|
2013-09-13 23:38:43 +00:00
|
|
|
g_free (outputuri);
|
2010-09-16 07:07:05 +00:00
|
|
|
exit (1);
|
2013-09-13 23:38:43 +00:00
|
|
|
}
|
|
|
|
g_free (outputuri);
|
2010-06-21 09:47:21 +00:00
|
|
|
|
2010-12-15 11:36:25 +00:00
|
|
|
gst_encoding_profile_unref (prof);
|
2010-04-20 11:08:27 +00:00
|
|
|
} else {
|
2014-02-17 11:34:04 +00:00
|
|
|
ges_pipeline_set_mode (pipeline, GES_PIPELINE_MODE_PREVIEW);
|
2010-04-20 11:08:27 +00:00
|
|
|
}
|
|
|
|
|
2011-11-30 14:44:45 +00:00
|
|
|
if (verbose) {
|
|
|
|
gchar **exclude_list =
|
|
|
|
exclude_args ? g_strsplit (exclude_args, ",", 0) : NULL;
|
|
|
|
g_signal_connect (pipeline, "deep-notify",
|
|
|
|
G_CALLBACK (gst_object_default_deep_notify), exclude_list);
|
|
|
|
}
|
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
/* Play the pipeline */
|
|
|
|
mainloop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
2010-07-15 17:50:22 +00:00
|
|
|
if (thumbinterval != 0.0) {
|
2011-01-17 15:46:15 +00:00
|
|
|
g_printf ("thumbnailing every %f seconds\n", thumbinterval);
|
2010-07-15 17:50:22 +00:00
|
|
|
g_timeout_add (1000 * thumbinterval, thumbnail_cb, pipeline);
|
|
|
|
}
|
|
|
|
|
2014-10-31 10:56:16 +00:00
|
|
|
if (!load_path) {
|
|
|
|
if (ges_validate_activate (GST_PIPELINE (pipeline), scenario,
|
|
|
|
&needs_set_state) == FALSE) {
|
|
|
|
g_error ("Could not activate scenario %s", scenario);
|
|
|
|
return 29;
|
|
|
|
}
|
2015-02-23 13:48:18 +00:00
|
|
|
|
|
|
|
if (!_timeline_set_user_options (timeline, NULL)) {
|
|
|
|
g_error ("Could not properly set tracks");
|
|
|
|
return 29;
|
|
|
|
}
|
2014-07-27 13:42:42 +00:00
|
|
|
}
|
|
|
|
|
2010-04-20 11:08:27 +00:00
|
|
|
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
|
|
gst_bus_add_signal_watch (bus);
|
|
|
|
g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), mainloop);
|
|
|
|
|
2014-10-30 11:38:16 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
signal_watch_id =
|
|
|
|
g_unix_signal_add (SIGINT, (GSourceFunc) intr_handler, pipeline);
|
|
|
|
#endif
|
|
|
|
|
2014-09-19 15:14:51 +00:00
|
|
|
if (!load_path) {
|
|
|
|
if (needs_set_state && gst_element_set_state (GST_ELEMENT (pipeline),
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
|
|
|
|
g_error ("Failed to start the pipeline\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2010-04-20 11:08:27 +00:00
|
|
|
}
|
|
|
|
g_main_loop_run (mainloop);
|
|
|
|
|
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
|
|
|
|
2014-09-25 12:55:15 +00:00
|
|
|
/* Re save the timeline in case the scenario changed it! */
|
|
|
|
_save_timeline (timeline, load_path);
|
|
|
|
|
2013-09-13 21:15:21 +00:00
|
|
|
validate_res = ges_validate_clean (GST_PIPELINE (pipeline));
|
|
|
|
if (seenerrors == FALSE)
|
|
|
|
seenerrors = validate_res;
|
2010-06-17 09:45:27 +00:00
|
|
|
|
2014-10-30 11:38:16 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
g_source_remove (signal_watch_id);
|
|
|
|
#endif
|
|
|
|
|
2010-09-16 07:07:05 +00:00
|
|
|
return (int) seenerrors;
|
2010-04-20 11:08:27 +00:00
|
|
|
}
|