diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c
index b9626ed..2efce04 100644
--- a/gst/qtdemux/qtdemux.c
+++ b/gst/qtdemux/qtdemux.c
@@ -1918,9 +1918,9 @@ static GstFlowReturn
 gst_qtdemux_seek_to_previous_keyframe (GstQTDemux * qtdemux)
 {
   guint8 n = 0;
-  guint32 seg_idx = 0, k_index = 0;
-  guint64 k_pos = 0, last_stop = 0;
-  QtDemuxSegment *seg = NULL;
+  guint32 seg_idx = 0, ref_k_index = 0;
+  guint64 ref_k_pos = 0, last_stop = 0;
+  QtDemuxSegment *ref_seg = NULL;
   QtDemuxStream *ref_str = NULL;
   guint64 seg_media_start_mov;  /* segment media start time in mov format */
 
@@ -1964,43 +1964,45 @@ gst_qtdemux_seek_to_previous_keyframe (GstQTDemux * qtdemux)
    * get the timestamp of the previous sample and search for a keyframe before
    * that. For audio streams we do an arbitrary jump in the past (10 samples) */
   if (ref_str->subtype == FOURCC_vide) {
-    k_index = gst_qtdemux_find_keyframe (qtdemux, ref_str,
+    ref_k_index = gst_qtdemux_find_keyframe (qtdemux, ref_str,
         ref_str->from_sample - 1);
-  } else {
-    if (ref_str->from_sample >= 10)
-      k_index = ref_str->from_sample - 10;
-    else
-      k_index = 0;
-  }
+	} else {
+		if (ref_str->from_sample >= 10)
+			ref_k_index = ref_str->from_sample - 10;
+		else
+			ref_k_index = 0;
+	}
 
   /* get current segment for that stream */
-  seg = &ref_str->segments[ref_str->segment_index];
+  ref_seg = &ref_str->segments[ref_str->segment_index];
   /* convert seg->media_start to mov format time for timestamp comparison */
   seg_media_start_mov =
-      gst_util_uint64_scale (seg->media_start, ref_str->timescale, GST_SECOND);
+      gst_util_uint64_scale (ref_seg->media_start, ref_str->timescale, GST_SECOND);
   /* Crawl back through segments to find the one containing this I frame */
-  while (ref_str->samples[k_index].timestamp < seg_media_start_mov) {
-    GST_DEBUG_OBJECT (qtdemux, "keyframe position is out of segment %u",
-        ref_str->segment_index);
-    if (G_UNLIKELY (!ref_str->segment_index)) {
-      /* Reached first segment, let's consider it's EOS */
-      goto eos;
-    }
-    ref_str->segment_index--;
-    seg = &ref_str->segments[ref_str->segment_index];
-  }
+	while (ref_str->samples[ref_k_index].timestamp < seg_media_start_mov) {
+		GST_DEBUG_OBJECT (qtdemux, "keyframe position is out of segment %u",
+				ref_str->segment_index);
+		if (G_UNLIKELY (!ref_str->segment_index)) {
+			/* Reached first segment, let's consider it's EOS */
+			goto eos;
+		}
+		ref_str->segment_index--;
+		ref_seg = &ref_str->segments[ref_str->segment_index];
+		seg_media_start_mov =
+			gst_util_uint64_scale (ref_seg->media_start, ref_str->timescale, GST_SECOND);
+	}
   /* Calculate time position of the keyframe and where we should stop */
-  k_pos =
-      (gst_util_uint64_scale (ref_str->samples[k_index].timestamp, GST_SECOND,
-          ref_str->timescale) - seg->media_start) + seg->time;
+  ref_k_pos =
+      (gst_util_uint64_scale (ref_str->samples[ref_k_index].timestamp, GST_SECOND,
+          ref_str->timescale) - ref_seg->media_start) + ref_seg->time;
   last_stop =
       gst_util_uint64_scale (ref_str->samples[ref_str->from_sample].timestamp,
       GST_SECOND, ref_str->timescale);
-  last_stop = (last_stop - seg->media_start) + seg->time;
+  last_stop = (last_stop - ref_seg->media_start) + ref_seg->time;
 
   GST_DEBUG_OBJECT (qtdemux, "preferred stream played from sample %u, "
       "now going to sample %u (pts %" GST_TIME_FORMAT ")", ref_str->from_sample,
-      k_index, GST_TIME_ARGS (k_pos));
+      ref_k_index, GST_TIME_ARGS (ref_k_pos));
 
   /* Set last_stop with the keyframe timestamp we pushed of that stream */
   gst_segment_set_last_stop (&qtdemux->segment, GST_FORMAT_TIME, last_stop);
@@ -2014,31 +2016,41 @@ gst_qtdemux_seek_to_previous_keyframe (GstQTDemux * qtdemux)
 
   /* Align them all on this */
   for (n = 0; n < qtdemux->n_streams; n++) {
-    guint32 index = 0;
-    guint64 media_start = 0, seg_time = 0;
+		guint32 k_index = 0;
     QtDemuxStream *str = qtdemux->streams[n];
+		QtDemuxSegment *seg = NULL;
 
-    seg_idx = gst_qtdemux_find_segment (qtdemux, str, k_pos);
-    GST_DEBUG_OBJECT (qtdemux, "align segment %d", seg_idx);
+		if (str != ref_str) {
+			guint32 index = 0;
+      guint64 media_start = 0, seg_time = 0;
 
-    /* segment not found, continue with normal flow */
-    if (seg_idx == -1)
-      continue;
+			seg_idx = gst_qtdemux_find_segment (qtdemux, str, ref_k_pos);
+			GST_DEBUG_OBJECT (qtdemux, "align segment %d", seg_idx);
 
-    /* get segment and time in the segment */
-    seg = &str->segments[seg_idx];
-    seg_time = k_pos - seg->time;
+			/* segment not found, continue with normal flow */
+			if (seg_idx == -1)
+				continue;
 
-    /* get the media time in the segment */
-    media_start = seg->media_start + seg_time;
+			/* get segment and time in the segment */
+			seg = &str->segments[seg_idx];
+			seg_time = ref_k_pos - seg->time;
 
-    /* get the index of the sample with media time */
-    index = gst_qtdemux_find_index (qtdemux, str, media_start);
-    GST_DEBUG_OBJECT (qtdemux, "sample for %" GST_TIME_FORMAT " at %u",
-        GST_TIME_ARGS (media_start), index);
+			/* get the media time in the segment */
+			media_start = seg->media_start + seg_time;
 
-    /* find previous keyframe */
-    k_index = gst_qtdemux_find_keyframe (qtdemux, str, index);
+			/* get the index of the sample with media time */
+			index = gst_qtdemux_find_index (qtdemux, str, media_start);
+			GST_DEBUG_OBJECT (qtdemux, "sample for %" GST_TIME_FORMAT " at %u",
+					GST_TIME_ARGS (media_start), index);
+
+			/* find previous keyframe */
+			k_index = gst_qtdemux_find_keyframe (qtdemux, str, index);
+
+		} else {
+			str = ref_str;
+      seg = ref_seg;
+      k_index = ref_k_index;
+		}
 
     /* Remember until where we want to go */
     str->to_sample = str->from_sample - 1;
