Index: libs/libmythtv/avformatdecoder.cpp
===================================================================
--- libs/libmythtv/avformatdecoder.cpp	(revision 9378)
+++ libs/libmythtv/avformatdecoder.cpp	(working copy)
@@ -982,6 +982,8 @@
             return 3;
         case CODEC_ID_MPEG4:
             return 4;
+        case CODEC_ID_H264:
+            return 4;
 #endif
     }
     return 0;
@@ -1103,10 +1105,11 @@
     {
         AVCodecContext *enc = ic->streams[i]->codec;
         VERBOSE(VB_PLAYBACK, LOC +
-                QString("Stream #%1, has id 0x%2 codec id %3, type %4 at 0x")
+                QString("Stream #%1, has id 0x%2 codec id %3, type %4, bitrate %5 at 0x")
                 .arg(i).arg((int)ic->streams[i]->id)
                 .arg(codec_id_string(enc->codec_id))
                 .arg(codec_type_string(enc->codec_type))
+                .arg(enc->bit_rate)
                 <<((void*)ic->streams[i]));
 
         switch (enc->codec_type)
@@ -1114,6 +1117,13 @@
             case CODEC_TYPE_VIDEO:
             {
                 assert(enc->codec_id);
+                
+                // HACK -- begin
+                // Force some bullshit bitrate on H.264
+                if (enc->codec_id == CODEC_ID_H264 && enc->bit_rate == 0)
+                    enc->bit_rate = 500;
+                // HACK -- end
+                
                 bitrate += enc->bit_rate;
                 if (novideo)
                     break;
@@ -1148,9 +1158,17 @@
                     }
                 }
                 else
+                {
+                    if (CODEC_ID_H264 == enc->codec_id)
+                        video_codec_id = kCodec_H264;
+                    else
+                        video_codec_id = kCodec_MPEG2; // default to MPEG2
+                }
+#else
+                if (CODEC_ID_H264 == enc->codec_id)
+                    video_codec_id = kCodec_H264;
+                else
                     video_codec_id = kCodec_MPEG2; // default to MPEG2
-#else
-                video_codec_id = kCodec_MPEG2; // default to MPEG2
 #endif // USING_XVMC
                 if (enc->codec)
                 {
@@ -2746,6 +2764,33 @@
     return true;
 }
 
+QString AvFormatDecoder::GetEncodingType(void) const
+{
+    switch (video_codec_id)
+    {
+        case kCodec_MPEG1:
+        case kCodec_MPEG1_XVMC:
+        case kCodec_MPEG1_VLD:
+        case kCodec_MPEG2:
+        case kCodec_MPEG2_IDCT:
+        case kCodec_MPEG2_VLD:
+            return QString("MPEG-2");
+
+        case kCodec_H264:
+        case kCodec_H264_XVMC:
+        case kCodec_H264_IDCT:
+        case kCodec_H264_VLD:
+            return QString("H.264");
+
+        default:
+            // defaults to MPEG-2
+            return QString("MPEG-2");
+    }
+
+    // defaults to MPEG-2
+    return QString("MPEG-2");
+}
+
 void AvFormatDecoder::SetDisablePassThrough(bool disable)
 {
     if (selectedTrack[kTrackTypeAudio].av_stream_index < 0)
Index: libs/libmythtv/libmythtv.pro
===================================================================
--- libs/libmythtv/libmythtv.pro	(revision 9378)
+++ libs/libmythtv/libmythtv.pro	(working copy)
@@ -284,8 +284,10 @@
     using_v4l {
         HEADERS += channel.h                   pchdtvsignalmonitor.h
         HEADERS += hdtvrecorder.h              analogscan.h
+        HEADERS += vloopbackrecorder.h
         SOURCES += channel.cpp                 pchdtvsignalmonitor.cpp
         SOURCES += hdtvrecorder.cpp            analogscan.cpp
+        SOURCES += vloopbackrecorder.cpp
 
         DEFINES += USING_V4L
     }
Index: libs/libmythtv/videodev2_myth.h
===================================================================
--- libs/libmythtv/videodev2_myth.h	(revision 9378)
+++ libs/libmythtv/videodev2_myth.h	(working copy)
@@ -338,16 +338,19 @@
 	V4L2_MPEG_AU_2_III,	/* MPEG-2 layer 3 */
 	V4L2_MPEG_AC3,		/* AC3 */
 	V4L2_MPEG_LPCM,		/* LPCM */
+	V4L2_MPEG_AUDIO_UNKNOWN = 0xff,
 };
 enum v4l2_mpeg_videotype {
 	V4L2_MPEG_VI_1,		/* MPEG-1 */
 	V4L2_MPEG_VI_2,		/* MPEG-2 */
+	V4L2_MPEG_VIDEO_UNKNOWN = 0xff,
 };
 enum v4l2_mpeg_aspectratio {
 	V4L2_MPEG_ASPECT_SQUARE = 1,   /* square pixel */
 	V4L2_MPEG_ASPECT_4_3    = 2,   /*  4 : 3       */
 	V4L2_MPEG_ASPECT_16_9   = 3,   /* 16 : 9       */
 	V4L2_MPEG_ASPECT_1_221  = 4,   /*  1 : 2,21    */
+	V4L2_MPEG_ASPECT_UNKNOWN = 0xff,
 };
 
 struct v4l2_mpeg_compression {
Index: libs/libmythtv/videoout_xv.cpp
===================================================================
--- libs/libmythtv/videoout_xv.cpp	(revision 9378)
+++ libs/libmythtv/videoout_xv.cpp	(working copy)
@@ -3337,6 +3337,9 @@
         case kCodec_MPEG4:
             ret = CODEC_ID_MPEG4;
             break;
+        case kCodec_H264:
+            ret = CODEC_ID_H264;
+            break;
 
         case kCodec_MPEG1_XVMC:
             mc = true;
@@ -3352,6 +3355,9 @@
         case kCodec_MPEG4_XVMC:
             VERBOSE(VB_IMPORTANT, "Error: XvMC MPEG4 not supported by ffmpeg");
             break;
+        case kCodec_H264_XVMC:
+            VERBOSE(VB_IMPORTANT, "Error: XvMC H264 not supported by ffmpeg");
+            break;
 
         case kCodec_MPEG1_IDCT:
             idct = mc = true;
@@ -3367,6 +3373,9 @@
         case kCodec_MPEG4_IDCT:
             VERBOSE(VB_IMPORTANT, "Error: XvMC-IDCT MPEG4 not supported by ffmpeg");
             break;
+        case kCodec_H264_IDCT:
+            VERBOSE(VB_IMPORTANT, "Error: XvMC-IDCT H264 not supported by ffmpeg");
+            break;
 
         case kCodec_MPEG1_VLD:
             vld = true;
@@ -3382,6 +3391,9 @@
         case kCodec_MPEG4_VLD:
             VERBOSE(VB_IMPORTANT, "Error: XvMC-VLD MPEG4 not supported by ffmpeg");
             break;
+        case kCodec_H264_VLD:
+            VERBOSE(VB_IMPORTANT, "Error: XvMC-VLD H264 not supported by ffmpeg");
+            break;
         default:
             VERBOSE(VB_IMPORTANT, QString("Error: MythCodecID %1 has not been "
                                           "added to myth2av_codecid")
Index: libs/libmythtv/avformatdecoder.h
===================================================================
--- libs/libmythtv/avformatdecoder.h	(revision 9378)
+++ libs/libmythtv/avformatdecoder.h	(working copy)
@@ -114,8 +114,7 @@
     /// This is a No-op for this class.
     long UpdateStoredFrameNum(long frame) { (void)frame; return 0;}
 
-    QString GetEncodingType(void) const { return QString("MPEG-2"); }
-
+    QString GetEncodingType(void) const;
     MythCodecID GetVideoCodecID() const { return video_codec_id; }
 
     virtual void SetDisablePassThrough(bool disable);
Index: libs/libmythtv/tv_rec.cpp
===================================================================
--- libs/libmythtv/tv_rec.cpp	(revision 9378)
+++ libs/libmythtv/tv_rec.cpp	(working copy)
@@ -46,6 +46,7 @@
 
 #ifdef USING_V4L
 #include "channel.h"
+#include "vloopbackrecorder.h"
 #endif
 
 #ifdef USING_IVTV
@@ -180,6 +181,17 @@
         InitChannel(genOpt.defaultinput, startchannel);
         init_run = true;
     }
+    else if (genOpt.cardtype == "VLOOPBACK")
+    {
+#ifdef USING_V4L
+        channel = new DummyChannel(this);
+        InitChannel(genOpt.defaultinput, startchannel);
+        init_run = true;
+
+        // vloopback_crc only supports MPEG2 TS right now
+        rbFileExt = "ts";
+#endif // USING_V4L
+    }
     else // "V4L" or "MPEG", ie, analog TV, or "HDTV"
     {
 #ifdef USING_V4L
@@ -223,6 +235,7 @@
     if (!GetDevices(cardid, genOpt, dvbOpt, fwOpt, dboxOpt))
         return false;
 
+    // configure the Channel instance
     QString startchannel = GetStartChannel(cardid, genOpt.defaultinput);
     if (!CreateChannel(startchannel))
         return false;
@@ -824,6 +837,14 @@
         recorder->SetOption("wait_for_seqstart", genOpt.wait_for_seqstart);
 #endif // USING_V4L
     }
+    else if (genOpt.cardtype == "VLOOPBACK")
+    {
+#ifdef USING_V4L
+        recorder = new VloopbackRecorder(this);
+        recorder->SetOption("wait_for_seqstart", genOpt.wait_for_seqstart);
+        ringBuffer->SetWriteBufferSize(4*1024*1024);
+#endif // USING_V4L
+    }
     else if (genOpt.cardtype == "FIREWIRE")
     {
 #ifdef USING_FIREWIRE
Index: libs/libmythtv/videooutbase.h
===================================================================
--- libs/libmythtv/videooutbase.h	(revision 9378)
+++ libs/libmythtv/videooutbase.h	(working copy)
@@ -41,6 +41,7 @@
     kCodec_MPEG2,
     kCodec_H263,
     kCodec_MPEG4,
+    kCodec_H264,
     
     kCodec_NORMAL_END,
 
@@ -48,11 +49,13 @@
     kCodec_MPEG2_XVMC,
     kCodec_H263_XVMC,
     kCodec_MPEG4_XVMC,
+    kCodec_H264_XVMC,
 
     kCodec_MPEG1_IDCT,
     kCodec_MPEG2_IDCT,
     kCodec_H263_IDCT,
     kCodec_MPEG4_IDCT,
+    kCodec_H264_IDCT,
 
     kCodec_STD_XVMC_END,
 
@@ -60,6 +63,7 @@
     kCodec_MPEG2_VLD,
     kCodec_H263_VLD,
     kCodec_MPEG4_VLD,
+    kCodec_H264_VLD,
 
     kCodec_SPECIAL_END,
 };


