[gegl] gcut: add ability to slow down/speed up clips
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gcut: add ability to slow down/speed up clips
- Date: Thu, 27 Jul 2017 22:40:13 +0000 (UTC)
commit b6a36e7990fb5c6738c09edc2dd418021c8d587c
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Jul 28 00:35:55 2017 +0200
gcut: add ability to slow down/speed up clips
When speeding up or slowing down clips, gcut currently only ever uses the
nearest full frame and doesn't do any blending between frames. I haven't tested
this well, but suspect that with 60fps source footage, one can do nice half
speed slow downs as well as speed ups of the footage without trouble if the
target is 30fps.
Adding the capability of doing higher quality inter frame motion interpolation
based would be possible in the future, but would high quality data the current
might be sufficient.
This is also the method used by gcut when mixing videos of different fps, not
ideal but it should do the job of having video.
gcut/clip.c | 10 +++++++---
gcut/gcut.c | 11 ++++++++++-
gcut/gcut.h | 10 +++++-----
3 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/gcut/clip.c b/gcut/clip.c
index c096b00..92ba4cf 100644
--- a/gcut/clip.c
+++ b/gcut/clip.c
@@ -11,6 +11,7 @@ Clip *clip_new (GeglEDL *edl)
Clip *clip = g_malloc0 (sizeof (Clip));
clip->edl = edl;
clip->gegl = gegl_node_new ();
+ clip->rate = 1.0;
clip->chain_loader = gegl_node_new_child (clip->gegl, "operation", "gegl:nop", NULL);
@@ -409,7 +410,10 @@ static void clip_rig_chain (Clip *clip, double clip_pos)
void clip_render_pos (Clip *clip, double clip_frame_pos)
{
- clip_rig_chain (clip, clip_frame_pos);
+ double pos =
+ clip->start + (clip_frame_pos - clip->start) * clip->rate;
+
+ clip_rig_chain (clip, pos);
g_mutex_lock (&clip->mutex);
gegl_node_process (clip->loader); // for the audio fetch
clip_fetch_audio (clip);
@@ -427,8 +431,8 @@ gchar *clip_get_pos_hash (Clip *clip, double clip_frame_pos)
// quantize to clip/project fps
//clip_frame_pos = ((int)(clip_frame_pos * clip_fps (clip) + 0.5))/ clip_fps (clip);
- frame_recipe = g_strdup_printf ("%s: %s %.3f %s %ix%i",
- "gcut-pre-4",
+ frame_recipe = g_strdup_printf ("%s: %.3f %s %.3f %s %ix%i",
+ "gcut-pre-4", clip->rate,
clip_get_path (clip),
clip->filter_graph || (!is_static_source) ? clip_frame_pos : 0.0,
clip->filter_graph,
diff --git a/gcut/gcut.c b/gcut/gcut.c
index f58d0f7..a25830f 100644
--- a/gcut/gcut.c
+++ b/gcut/gcut.c
@@ -656,10 +656,17 @@ void gcut_parse_line (GeglEDL *edl, const char *line)
while (*rest && *rest != ']'){ rest++;}
if (*rest == ']') rest++;
}
+ if (rest && strstr (rest, "[rate="))
+ {
+ ff_probe = 1;
+ rest = strstr (rest, "[rate=") + strlen ("[rate=");
+ clip->rate = g_strtod (rest, NULL);
+ while (*rest && *rest != ']'){ rest++;}
+ if (*rest == ']') rest++;
+ }
if (rest) while (*rest == ' ')rest++;
-
if (clip == edl->clips->data || clip->fps < 0.001)
{
ff_probe = 1;
@@ -1490,6 +1497,8 @@ char *gcut_serialize (GeglEDL *edl)
g_string_append_printf (ser, "[fade=%.3fs] ", clip->fade);
if (clip->fps>0.001)
g_string_append_printf (ser, "[fps=%.3f] ", clip->fps);
+ if (fabs(clip->rate - 1.0 )>0.001)
+ g_string_append_printf (ser, "[rate=%.5f] ", clip->rate);
if (clip->filter_graph)
g_string_append_printf (ser, "%s", clip->filter_graph);
g_string_append_printf (ser, "\n");
diff --git a/gcut/gcut.h b/gcut/gcut.h
index e4c294d..bcc58f0 100644
--- a/gcut/gcut.h
+++ b/gcut/gcut.h
@@ -9,10 +9,6 @@
move gcut to gegl git repo
engine
- use seconds instead of frames [done]
- ::rescaling playback speed of clips
- ::support importing clips of different fps
-
support for configuring the final background render to be as high
fidelity as GEGL processing allows - rather than sharing tuning for
preview rendering.
@@ -150,7 +146,11 @@ struct _Clip
GeglEDL *edl;
double fps;
- double fade; /* the main control for fading in.. */
+ double fade; /* the control is for the fade in of the clip - potential
+ fade out is controlled by next clip */
+
+ double rate; /* playback rate, 1.0 = realtime */
+
int static_source;
int is_chain;
int is_meta;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]