diff --git a/ext/theora/theoraenc.c b/ext/theora/theoraenc.c
index 6704a57..6d3576e 100644
--- a/ext/theora/theoraenc.c
+++ b/ext/theora/theoraenc.c
@@ -757,6 +757,11 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
 
   running_time =
       gst_segment_to_running_time (&enc->segment, GST_FORMAT_TIME, timestamp);
+  if ((gint64)running_time < 0) {
+    GST_DEBUG_OBJECT (enc, "Clipping buffer, timestamp: %" GST_TIME_FORMAT,
+        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
+    return GST_FLOW_OK;
+  }
 
   /* see if we need to schedule a keyframe */
   GST_OBJECT_LOCK (enc);
diff --git a/ext/vorbis/vorbisenc.c b/ext/vorbis/vorbisenc.c
index 55bf849..d4f4983 100644
--- a/ext/vorbis/vorbisenc.c
+++ b/ext/vorbis/vorbisenc.c
@@ -893,7 +893,8 @@ gst_vorbis_enc_buffer_from_packet (GstVorbisEnc * vorbisenc,
   /* update the next timestamp, taking granulepos_offset and subgranule offset
    * into account */
   vorbisenc->next_ts =
-      granulepos_to_timestamp_offset (vorbisenc, packet->granulepos);
+      granulepos_to_timestamp_offset (vorbisenc, packet->granulepos) +
+      vorbisenc->initial_ts;
   GST_BUFFER_DURATION (outbuf) =
       vorbisenc->next_ts - GST_BUFFER_TIMESTAMP (outbuf);
 
@@ -1097,18 +1098,24 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
   GstBuffer *buf1, *buf2, *buf3;
   gboolean first = FALSE;
   GstClockTime timestamp = GST_CLOCK_TIME_NONE;
+  GstClockTime running_time = GST_CLOCK_TIME_NONE;
 
   vorbisenc = GST_VORBISENC (GST_PAD_PARENT (pad));
 
   if (!vorbisenc->setup)
     goto not_setup;
 
-  timestamp =
+  running_time =
       gst_segment_to_running_time (&vorbisenc->segment, GST_FORMAT_TIME,
-      GST_BUFFER_TIMESTAMP (buffer)) + vorbisenc->initial_ts;
+      GST_BUFFER_TIMESTAMP (buffer));
+  if ((gint64)running_time < 0) {
+    GST_DEBUG_OBJECT (vorbisenc, "Clipping buffer, timestamp: %" GST_TIME_FORMAT,
+        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
+    return GST_FLOW_OK;
+  }
+  timestamp = running_time + vorbisenc->initial_ts;
   GST_DEBUG_OBJECT (vorbisenc, "Initial ts is %" GST_TIME_FORMAT,
       GST_TIME_ARGS (vorbisenc->initial_ts));
-
   if (!vorbisenc->header_sent) {
     /* Vorbis streams begin with three headers; the initial header (with
        most of the codec setup parameters) which is mandated by the Ogg
@@ -1168,10 +1175,11 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
     vorbisenc->next_ts = timestamp;
     vorbisenc->expected_ts = timestamp;
     vorbisenc->granulepos_offset = gst_util_uint64_scale
-        (timestamp, vorbisenc->frequency, GST_SECOND);
+        (running_time, vorbisenc->frequency, GST_SECOND);
     vorbisenc->subgranule_offset = 0;
     vorbisenc->subgranule_offset =
-        vorbisenc->next_ts - granulepos_to_timestamp_offset (vorbisenc, 0);
+        (vorbisenc->next_ts - vorbisenc->initial_ts) - 
+	granulepos_to_timestamp_offset (vorbisenc, 0);
 
     vorbisenc->header_sent = TRUE;
     first = TRUE;
@@ -1221,7 +1229,7 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
     /* We need to round to the nearest whole number of samples, not just do
      * a truncating division here */
     vorbisenc->granulepos_offset = gst_util_uint64_scale
-        (timestamp + GST_SECOND / vorbisenc->frequency / 2
+        (running_time + GST_SECOND / vorbisenc->frequency / 2
         - vorbisenc->subgranule_offset, vorbisenc->frequency, GST_SECOND);
 
     vorbisenc->header_sent = TRUE;
