Index: mythtv/libs/libmythtv/recorderbase.cpp
===================================================================
--- mythtv/libs/libmythtv/recorderbase.cpp	(revision 18528)
+++ mythtv/libs/libmythtv/recorderbase.cpp	(working copy)
@@ -5,8 +5,8 @@
 #include "tv_rec.h"
 #include "libmythdb/mythverbose.h"
 #include "RingBuffer.h"
+#include "recordingprofile.h"
 #include "programinfo.h"
-#include "recordingprofile.h"
 #include "util.h"
 
 #define TVREC_CARDNUM \
@@ -23,7 +23,7 @@
     : tvrec(rec), ringBuffer(NULL), weMadeBuffer(true), videocodec("rtjpeg"),
       audiodevice("/dev/dsp"), videodevice("/dev/video"), vbidevice("/dev/vbi"),
       vbimode(0), ntsc(true), ntsc_framerate(true), video_frame_rate(29.97),
-      curRecording(NULL), request_pause(false), paused(false),
+      m_videoAspect(0), curRecording(NULL), request_pause(false), paused(false),
       nextRingBuffer(NULL), nextRecording(NULL),
       positionMapType(MARK_GOP_BYFRAME), positionMapLock(false)
 {
@@ -237,6 +237,9 @@
 
     if (rb_changed && tvrec)
         tvrec->RingBufferChanged(ringBuffer, curRecording);
+
+    if (rb_changed)
+        m_videoAspect = 0;
 }
 
 /** \fn RecorderBase::SavePositionMap(bool)
@@ -274,4 +277,29 @@
         positionMapLock.unlock();
 }
 
+void RecorderBase::AspectChange(AspectRatio aspect, long long frame)
+{
+    MarkTypes mark;
+    switch (aspect)
+    {
+        case ASPECT_1_1 :
+            mark = MARK_ASPECT_1_1;
+            break;
+        case ASPECT_4_3 :
+            mark = MARK_ASPECT_4_3;
+            break;
+        case ASPECT_16_9 :
+            mark = MARK_ASPECT_16_9;
+            break;
+        case ASPECT_21_1_1 :
+            mark = MARK_ASPECT_21_1_1;
+            break;
+        default :
+            mark = MARK_ASPECT_4_3;
+    }
+
+    if (curRecording)
+        curRecording->SetAspectChange(mark, frame);
+}
+
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
Index: mythtv/libs/libmythtv/recorderbase.h
===================================================================
--- mythtv/libs/libmythtv/recorderbase.h	(revision 18528)
+++ mythtv/libs/libmythtv/recorderbase.h	(working copy)
@@ -212,6 +212,14 @@
      */
     void SavePositionMap(bool force = false);
 
+    enum AspectRatio {
+        ASPECT_UNKNOWN       = 0x00,
+        ASPECT_1_1           = 0x01,
+        ASPECT_4_3           = 0x02,
+        ASPECT_16_9          = 0x03,
+        ASPECT_21_1_1         = 0x04
+    };
+
   protected:
     /** \brief Convenience function used to set integer options from a profile.
      *  \sa SetOption(const QString&, int)
@@ -231,6 +239,10 @@
      */
     void SetPositionMapType(int type) { positionMapType = type; }
 
+    /** \brief Note a change in aspect ratio in the recordedmark table
+     */
+    void AspectChange(AspectRatio ratio, long long frame);
+
     TVRec         *tvrec;
     RingBuffer    *ringBuffer;
     bool           weMadeBuffer;
@@ -245,6 +257,8 @@
     bool           ntsc_framerate;
     double         video_frame_rate;
 
+    uint           m_videoAspect; // AspectRatio
+
     ProgramInfo   *curRecording;
 
     // For handling pausing
@@ -263,6 +277,7 @@
     QMutex                     positionMapLock;
     QMap<long long, long long> positionMap;
     QMap<long long, long long> positionMapDelta;
+
 };
 
 #endif
Index: mythtv/libs/libmythtv/dtvrecorder.cpp
===================================================================
--- mythtv/libs/libmythtv/dtvrecorder.cpp	(revision 18528)
+++ mythtv/libs/libmythtv/dtvrecorder.cpp	(working copy)
@@ -261,6 +261,8 @@
     bool hasFrame     = false;
     bool hasKeyFrame  = false;
 
+    uint aspectRatio;
+
     // Scan for PES header codes; specifically picture_start
     // sequence_start (SEQ) and group_start (GOP).
     //   00 00 01 00: picture_start_code
@@ -289,6 +291,10 @@
             {
                 _last_seq_seen  = _frames_seen_count;
                 hasKeyFrame    |= (_last_gop_seen + maxKFD)<_frames_seen_count;
+
+                // Look for aspectRatio changes and store them in the database
+                aspectRatio = (bufptr[3] >> 4);
+                //int frameRate = (bufptr[3] & 0x0000000f);
             }
         }
     }
@@ -317,6 +323,12 @@
             _frames_written_count++;
     }
 
+    if ((aspectRatio > 0) && (aspectRatio != m_videoAspect))
+    {
+        m_videoAspect = aspectRatio;
+        AspectChange((AspectRatio)aspectRatio, _frames_written_count);
+    }
+
     return hasKeyFrame || (_payload_buffer.size() >= (188*50));
 }
 
Index: mythtv/libs/libmythtv/programinfo.cpp
===================================================================
--- mythtv/libs/libmythtv/programinfo.cpp	(revision 18528)
+++ mythtv/libs/libmythtv/programinfo.cpp	(working copy)
@@ -2945,6 +2945,32 @@
     }
 }
 
+/**
+ *  \brief Store a change in aspect ratio in the recordedmark table
+ */
+void ProgramInfo::SetAspectChange(MarkTypes type, long long frame)
+{
+    if (isVideo)
+        return;
+
+    VERBOSE(VB_IMPORTANT, QString("Set Aspect Change: %1").arg((int)type));
+
+    MSqlQuery query(MSqlQuery::InitCon());
+
+    query.prepare("INSERT INTO recordedmarkup"
+                    " (chanid, starttime, mark, type)"
+                    " VALUES"
+                    " ( :CHANID , :STARTTIME , :MARK , :TYPE );");
+    query.bindValue(":CHANID", chanid);
+    query.bindValue(":STARTTIME", recstartts);
+
+    query.bindValue(":MARK", frame);
+    query.bindValue(":TYPE", type);
+
+    if (!query.exec() || !query.isActive())
+        MythDB::DBError("aspect ratio change insert", query);
+}
+
 /** \fn ProgramInfo::ReactivateRecording(void)
  *  \brief Asks the scheduler to restart this recording if possible.
  */
Index: mythtv/libs/libmythtv/programinfo.h
===================================================================
--- mythtv/libs/libmythtv/programinfo.h	(revision 18528)
+++ mythtv/libs/libmythtv/programinfo.h	(working copy)
@@ -41,7 +41,11 @@
     MARK_GOP_START = 6,
     MARK_KEYFRAME = 7,
     MARK_SCENE_CHANGE = 8,
-    MARK_GOP_BYFRAME = 9
+    MARK_GOP_BYFRAME = 9,
+    MARK_ASPECT_1_1 = 10,
+    MARK_ASPECT_4_3 = 11,
+    MARK_ASPECT_16_9 = 12,
+    MARK_ASPECT_21_1_1 = 13
 } MarkTypes;
 MPUBLIC QString toString(MarkTypes type);
 
@@ -307,6 +311,9 @@
     void SetPositionMapDBReplacement(PMapDBReplacement *pmap)
         { positionMapDBReplacement = pmap; }
 
+    // Aspect Ratio map
+    void SetAspectChange(MarkTypes type, long long frame);
+
     // GUI stuff
     void showDetails(void) const;
     void EditRecording(void);
