예제 #1
0
	attribute::Attribute& getSingleInputAttribute()
	{
		ofx::attribute::OfxhClipImageSet::ClipImageVector& clips = getClipsByOrder();
		ofx::attribute::OfxhClipImageSet::ClipImageMap& clipsMap = getClips();
		ofx::attribute::OfxhAttribute* inAttr                    = NULL;

		if( clips.size() == 1 )
		{
			inAttr = &clips[0];
		}
		else if( clips.size() > 1 )
		{
			const ofx::attribute::OfxhClipImageSet::ClipImageMap::iterator it( clipsMap.find( kOfxSimpleSourceAttributeName ) );
			if( it != clipsMap.end() )
			{
				inAttr = it->second;
			}
			else
			{
				inAttr = &clips[0];
			}
		}
		else // if( inClips.empty() )
		{
			BOOST_THROW_EXCEPTION( exception::Logic()
			    << exception::user( "No source clip." ) );
		}
		return dynamic_cast<attribute::ClipImage&>( *inAttr );
	}
예제 #2
0
void
render_json (const char *filename)
{
  JsonParser *parser;
  JsonNode *root;
  GError *error;
  parser = json_parser_new ();

  error = NULL;
  json_parser_load_from_file (parser, filename, &error);
  if (error) {
    g_print ("Parsing error `%s':\n %s\n", filename, error->message);
    g_error_free (error);
    g_object_unref (parser);
    exit (0);
  }

  root = json_parser_get_root (parser);

  JsonReader *reader = json_reader_new (root);
  GESTimeline *timeline;

  json_reader_read_member (reader, "composition");

  // comp strings
  const char *name = getString (reader, "name");
  //const char *src_dir = getString (reader, "src-dir");
  //g_print ("Source Directory: %s\nName: %s\n", src_dir, name);

  // comp ints
  int width = getInt (reader, "width");
  int height = getInt (reader, "height");
  int fps = getInt (reader, "fps");

  gboolean transparency = TRUE;

  if (is_in_members (reader, "transparency")) {
    transparency = getBool (reader, "transparency");
  }

  gboolean absolute_paths = FALSE;

  if (is_in_members (reader, "absolute_paths")) {
    absolute_paths = getBool (reader, "absolute_paths");
  }

  g_print ("Resolution: %dx%d, FPS: %d\n", width, height, fps);

  timeline = ges_timeline_new_audio_video ();

  int i;
  json_reader_read_member (reader, "layers");

  for (i = 0; i < json_reader_count_elements (reader); i++) {
    json_reader_read_element (reader, i);

    GESLayer *layer = ges_layer_new ();

    g_object_set (layer, "priority", i, NULL);

    if (is_in_members (reader, "autotransition")) {
      gboolean autotransition = getBool (reader, "autotransition");
      if (autotransition)
        g_print ("Auto Transitions on.\n");
      g_object_set (layer, "auto-transition", autotransition, NULL);
    }

    ges_timeline_add_layer (timeline, layer);

    getClips (reader, layer, GES_TRACK_TYPE_UNKNOWN, absolute_paths);

    json_reader_end_element (reader);
  }
  json_reader_end_member (reader);

  ges_timeline_commit (timeline);

  const gchar *xges_path = g_strconcat ("file://", filename, ".xges", NULL);

  ges_timeline_save_xges (timeline, xges_path);

  //free(xges_path);

  // formats
  GESRendererProfile res =
      { width, height, fps, PROFILE_AAC_H264_QUICKTIME, NULL };
  if (!transparency) {
    g_print ("Deactivating transparency\n");
    res.format = "I420";
  }

  json_reader_read_member (reader, "formats");
  for (i = 0; i < json_reader_count_elements (reader); i++) {
    json_reader_read_element (reader, i);
    const char *format = json_reader_get_string_value (reader);
    json_reader_end_element (reader);
    g_print ("format: %s\n", format);
    EncodingProfile prof = PROFILE_AAC_H264_QUICKTIME;
    if (strcmp (format, "webm") == 0) {
      prof = PROFILE_VORBIS_VP8_WEBM;
    } else if (strcmp (format, "mkv") == 0) {
      prof = PROFILE_VORBIS_H264_MATROSKA;
    } else if (strcmp (format, "mp4") == 0) {
      prof = PROFILE_AAC_H264_QUICKTIME;
    } else if (strcmp (format, "ogg") == 0) {
      prof = PROFILE_VORBIS_THEORA_OGG;
    }
    res.profile = prof;
    ges_renderer_render (timeline, name, &res, absolute_paths);
  }
  json_reader_end_member (reader);

  json_reader_end_member (reader);

  g_object_unref (reader);
  g_object_unref (parser);
}