diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c
index b06fe6b..7481431 100644
--- a/gst/mpegtsdemux/tsdemux.c
+++ b/gst/mpegtsdemux/tsdemux.c
@@ -143,9 +143,9 @@ struct _TSDemuxStream
   /* PTS/DTS with rollover fixed */
   guint64 fixed_pts;
   guint64 fixed_dts;
-  /* Number of rollover seen for PTS/DTS (default:0) */
-  guint nb_pts_rollover;
-  guint nb_dts_rollover;
+  /* offset for PTS/DTS, e.g. because of rollover */
+  gint64 pts_offset;
+  gint64 dts_offset;
 
   /* Whether this stream needs to send a newsegment */
   gboolean need_newsegment;
@@ -908,7 +908,8 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
       template = gst_static_pad_template_get (&video_template);
       name = g_strdup_printf ("video_%04x", bstream->pid);
       caps = gst_caps_new_simple ("video/x-wmv",
-          "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL);
+          "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC,
+          GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL);
 
       break;
     }
@@ -1051,8 +1052,8 @@ gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * bstream,
     stream->raw_dts = 0;
     stream->fixed_pts = 0;
     stream->fixed_dts = 0;
-    stream->nb_pts_rollover = 0;
-    stream->nb_dts_rollover = 0;
+    stream->pts_offset = 0;
+    stream->dts_offset = 0;
     stream->continuity_counter = CONTINUITY_UNSET;
   }
   stream->flow_return = GST_FLOW_OK;
@@ -1134,8 +1135,8 @@ gst_ts_demux_stream_flush (TSDemuxStream * stream)
   stream->raw_dts = 0;
   stream->fixed_pts = 0;
   stream->fixed_dts = 0;
-  stream->nb_pts_rollover = 0;
-  stream->nb_dts_rollover = 0;
+  stream->pts_offset = 0;
+  stream->dts_offset = 0;
   stream->continuity_counter = CONTINUITY_UNSET;
   if (stream->flow_return == GST_FLOW_WRONG_STATE) {
     stream->flow_return = GST_FLOW_OK;
@@ -1197,25 +1198,36 @@ gst_ts_demux_record_pts (GstTSDemux * demux, TSDemuxStream * stream,
   GST_LOG ("pid 0x%04x pts:%" G_GUINT64_FORMAT " at offset %"
       G_GUINT64_FORMAT, bs->pid, pts, offset);
 
-  if (G_UNLIKELY (GST_CLOCK_TIME_IS_VALID (stream->pts) &&
-          ABSDIFF (stream->raw_pts, pts) > 900000)) {
-    /* Detect rollover if diff > 10s */
-    GST_LOG ("Detected rollover (previous:%" G_GUINT64_FORMAT " new:%"
-        G_GUINT64_FORMAT ")", stream->raw_pts, pts);
-    if (pts < stream->raw_pts) {
-      /* Forward rollover */
-      GST_LOG ("Forward rollover, incrementing nb_pts_rollover");
-      stream->nb_pts_rollover++;
-    } else {
-      /* Reverse rollover */
-      GST_LOG ("Reverse rollover, decrementing nb_pts_rollover");
-      stream->nb_pts_rollover--;
+  if (GST_CLOCK_TIME_IS_VALID (stream->pts)) {
+    guint64 diff = ABSDIFF (stream->raw_pts, pts);
+
+    if (G_UNLIKELY (diff > PTS_DTS_MAX_VALUE / 2)) {
+      /* Detect rollover if diff > PTS_DTS_MAX_VALUE / 2 */
+      GST_LOG ("Detected rollover (previous:%" G_GUINT64_FORMAT " new:%"
+          G_GUINT64_FORMAT ")", stream->raw_pts, pts);
+      if (pts < stream->raw_pts) {
+        /* Forward rollover */
+        GST_LOG ("Forward rollover, incrementing offset");
+        stream->pts_offset += PTS_DTS_MAX_VALUE;
+      } else {
+        /* Reverse rollover */
+        GST_LOG ("Reverse rollover, decrementing offset");
+        stream->pts_offset -= PTS_DTS_MAX_VALUE;
+      }
+    } else if (G_UNLIKELY (diff > 15 * 90000)) {
+      /* PES reset */
+      GST_LOG ("Detected PES timestamp reset (previous:%" G_GUINT64_FORMAT " new:%"
+          G_GUINT64_FORMAT ")", stream->raw_pts, pts);
+      /* Calculate an offset to get the timestamp we would've expected next */
+      stream->pts_offset += stream->raw_pts - pts;
+      /* FIXME: But... this causes us to be one frame too early, we would need to add
+       * the duration of one frame here */
     }
   }
 
   /* Compute PTS in GstClockTime */
   stream->raw_pts = pts;
-  stream->fixed_pts = pts + stream->nb_pts_rollover * PTS_DTS_MAX_VALUE;
+  stream->fixed_pts = pts + stream->pts_offset;
   stream->pts = MPEGTIME_TO_GSTTIME (stream->fixed_pts);
 
   GST_LOG ("pid 0x%04x Stored PTS %" G_GUINT64_FORMAT " (%" GST_TIME_FORMAT ")",
@@ -1248,25 +1260,35 @@ gst_ts_demux_record_dts (GstTSDemux * demux, TSDemuxStream * stream,
   GST_LOG ("pid 0x%04x dts:%" G_GUINT64_FORMAT " at offset %"
       G_GUINT64_FORMAT, bs->pid, dts, offset);
 
-  if (G_UNLIKELY (GST_CLOCK_TIME_IS_VALID (stream->dts) &&
-          ABSDIFF (stream->raw_dts, dts) > 900000)) {
-    /* Detect rollover if diff > 10s */
-    GST_LOG ("Detected rollover (previous:%" G_GUINT64_FORMAT " new:%"
-        G_GUINT64_FORMAT ")", stream->raw_dts, dts);
-    if (dts < stream->raw_dts) {
-      /* Forward rollover */
-      GST_LOG ("Forward rollover, incrementing nb_dts_rollover");
-      stream->nb_dts_rollover++;
-    } else {
-      /* Reverse rollover */
-      GST_LOG ("Reverse rollover, decrementing nb_dts_rollover");
-      stream->nb_dts_rollover--;
+  if (GST_CLOCK_TIME_IS_VALID (stream->dts)) {
+    guint64 diff = ABSDIFF (stream->raw_dts, dts);
+
+    if (G_UNLIKELY (diff > PTS_DTS_MAX_VALUE / 2)) {
+      /* Detect rollover if diff > PTS_DTS_MAX_VALUE / 2 */
+      GST_LOG ("Detected rollover (previous:%" G_GUINT64_FORMAT " new:%"
+          G_GUINT64_FORMAT ")", stream->raw_dts, dts);
+      if (dts < stream->raw_dts) {
+        /* Forward rollover */
+        GST_LOG ("Forward rollover, incrementing offset");
+        stream->dts_offset += PTS_DTS_MAX_VALUE;
+      } else {
+        /* Reverse rollover */
+        GST_LOG ("Reverse rollover, decrementing offset");
+        stream->dts_offset -= PTS_DTS_MAX_VALUE;
+      }
+    } else if (G_UNLIKELY (diff > 15 * 90000)) {
+      /* PES reset */
+      GST_LOG ("Detected PES timestamp reset (previous:%" G_GUINT64_FORMAT " new:%"
+          G_GUINT64_FORMAT ")", stream->raw_dts, dts);
+      stream->dts_offset += stream->raw_dts - dts;
+      /* FIXME: But... this causes us to be one frame too early, we would need to add
+       * the duration of one frame here */
     }
   }
 
   /* Compute DTS in GstClockTime */
   stream->raw_dts = dts;
-  stream->fixed_dts = dts + stream->nb_dts_rollover * PTS_DTS_MAX_VALUE;
+  stream->fixed_dts = dts + stream->dts_offset;
   stream->dts = MPEGTIME_TO_GSTTIME (stream->fixed_dts);
 
   GST_LOG ("pid 0x%04x Stored DTS %" G_GUINT64_FORMAT " (%" GST_TIME_FORMAT ")",
