diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c
index 8460be0..cf73c17 100644
--- a/libs/gst/base/gstbasetransform.c
+++ b/libs/gst/base/gstbasetransform.c
@@ -2288,17 +2288,6 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer)
 
   trans = GST_BASE_TRANSFORM (GST_OBJECT_PARENT (pad));
 
-  timestamp = GST_BUFFER_TIMESTAMP (buffer);
-  duration = GST_BUFFER_DURATION (buffer);
-
-  /* calculate end position of the incoming buffer */
-  if (timestamp != GST_CLOCK_TIME_NONE) {
-    if (duration != GST_CLOCK_TIME_NONE)
-      last_stop = timestamp + duration;
-    else
-      last_stop = timestamp;
-  }
-
   klass = GST_BASE_TRANSFORM_GET_CLASS (trans);
   if (klass->before_transform)
     klass->before_transform (trans, buffer);
@@ -2312,6 +2301,17 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer)
    * GST_BASE_TRANSFORM_FLOW_DROPPED we will not push either. */
   if (outbuf != NULL) {
     if ((ret == GST_FLOW_OK)) {
+      timestamp = GST_BUFFER_TIMESTAMP (outbuf);
+      duration = GST_BUFFER_DURATION (outbuf);
+
+      /* calculate end position of the incoming buffer */
+      if (timestamp != GST_CLOCK_TIME_NONE) {
+        if (duration != GST_CLOCK_TIME_NONE)
+          last_stop = timestamp + duration;
+        else
+          last_stop = timestamp;
+      }
+
       /* Remember last stop position */
       if ((last_stop != GST_CLOCK_TIME_NONE) &&
           (trans->segment.format == GST_FORMAT_TIME))
