diff --git a/CMakeLists.txt b/CMakeLists.txt
index db4df77..3c3d248 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ macro_optional_find_package(QImageBlitz)
 macro_log_feature(QIMAGEBLITZ_FOUND "QImageBlitz" "An image effects library" "http://sourceforge.net/projects/qimageblitz" TRUE "kdesupport" "Required to build Okular.")

 add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
-add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DOKULAR_TEXTDOCUMENT_THREADED_RENDERING)
+add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) #-DOKULAR_TEXTDOCUMENT_THREADED_RENDERING)
 include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${KDE4_INCLUDES}
diff --git a/core/textdocumentgenerator.cpp b/core/textdocumentgenerator.cpp
index 4863fc7..774879e 100644
--- a/core/textdocumentgenerator.cpp
+++ b/core/textdocumentgenerator.cpp
@@ -29,6 +29,7 @@
 #include "textpage.h"

 #include "document.h"
+#include "document_p.h"

 using namespace Okular;

@@ -396,11 +397,12 @@ QImage TextDocumentGeneratorPrivate::image( PixmapRequest * request )
     p.translate( QPoint( 0, request->pageNumber() * size.height() * -1 ) );

 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
-    q->userMutex()->lock();
-    QTextDocument *cloned = mDocument->clone();
-    q->userMutex()->unlock();
-    cloned->drawContents( &p, rect);
-    delete cloned;
+    if(fname != m_document->m_docFileName){
+        if(cloned) delete cloned;
+        fname = m_document->m_docFileName;
+        cloned = mConverter->convert(fname);
+    }
+    cloned->drawContents( &p, rect );
 #else
     mDocument->drawContents( &p, rect );
 #endif
diff --git a/core/textdocumentgenerator_p.h b/core/textdocumentgenerator_p.h
index 42e9124..e688f13 100644
--- a/core/textdocumentgenerator_p.h
+++ b/core/textdocumentgenerator_p.h
@@ -114,12 +114,13 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate

     public:
         TextDocumentGeneratorPrivate( TextDocumentConverter *converter )
-            : mConverter( converter ), mDocument( 0 ), mGeneralSettings( 0 )
+            : mConverter( converter ), mDocument( 0 ), mGeneralSettings( 0 ), cloned ( 0 )
         {
         }

         virtual ~TextDocumentGeneratorPrivate()
         {
+            if(cloned) delete cloned;
             delete mConverter;
             delete mDocument;
         }
@@ -194,6 +195,10 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate
         TextDocumentSettings *mGeneralSettings;

         QFont mFont;
+
+        QTextDocument *cloned;
+
+        QString fname;
 };

 }
diff --git a/generators/epub/converter.cpp b/generators/epub/converter.cpp
index 1e754ec..d181d5b 100644
--- a/generators/epub/converter.cpp
+++ b/generators/epub/converter.cpp
@@ -18,6 +18,9 @@
 #include <kdebug.h>
 #include <klocale.h>
 #include <core/action.h>
+#include <core/sound.h>
+#include <core/movie.h>
+#include <core/annotations.h>

 using namespace Epub;

@@ -170,6 +173,7 @@ QTextDocument* Converter::convert( const QString &fileName )

   // if the background color of the document is non-white it will be handled by QTextDocument::setHtml()
   bool firstPage = true;
+  QVector<Okular::MovieAnnotation *> annots;
   do{
     if(epub_it_get_curr(it)) {
       const QString link = QString::fromUtf8(epub_it_get_curr_url(it));
@@ -210,8 +214,48 @@ QTextDocument* Converter::convert( const QString &fileName )
           }
           htmlContent = dom.toString();
         }
+      } else {
+          qFatal("error in doc parsing");
       }

+      QDomNodeList videos = dom.elementsByTagName("video");
+      if(!videos.isEmpty()) {
+          for (int i = 0; i < videos.size(); ++i) {
+              QDomNodeList sources = videos.at(i).toElement().elementsByTagName("source");
+              if(!sources.isEmpty()) {
+                  QString lnk = sources.at(0).toElement().attribute("src");
+                  QByteArray barr = mTextDocument->loadResource(QTextDocument::UserResource,QUrl(lnk)).toByteArray();
+                  QTemporaryFile *tmp = new QTemporaryFile( QString( "%1/okrjay" ).arg( QDir::tempPath() ) );
+                  if(tmp->open()) {
+                      tmp->write(barr);
+                      tmp->flush();
+                      //tmp->close();
+                  }
+                  Okular::Movie *mm = new Okular::Movie(tmp->fileName());
+                  //lnk = "/home/jaydeep/kde/okular-debug/bin/nfsr.mp4";
+                  //Okular::Movie *mm = new Okular::Movie(lnk);
+                  mm->setSize(QSize(320,240));
+                  mm->setRotation(Okular::Rotation0);
+                  mm->setShowControls(true);
+                  mm->setPlayMode(Okular::Movie::PlayRepeat);
+                  mm->setAutoPlay(false);
+                  Okular::MovieAnnotation *anot = new Okular::MovieAnnotation();
+                  anot->setAuthor("jaydp");
+                  anot->setMovie(mm);
+                  //anot->setBoundingRectangle(Okular::NormalizedRect(0.1,0.1,0.3,0.3));
+
+                  annots.push_back(anot);
+                  QDomDocument tempDoc;
+                  tempDoc.setContent(QString("<pre>&lt;video&gt;&lt;/video&gt;</pre>"));
+                  videos.at(i).parentNode().replaceChild(tempDoc.documentElement(),videos.at(i));
+                  //emit addAnnotation(anot, pos, _cursor->position()+1);
+              }
+          }
+      }
+      htmlContent = dom.toString();
+
+
+
       QTextBlock before;
       const QString css = "<style> body { color : "+ mTextDocument->txtColor.name()+"; }"
         " a { color : blue; }</style>";
@@ -241,6 +285,15 @@ QTextDocument* Converter::convert( const QString &fileName )

   epub_free_iterator(it);

+  QTextCursor csr(mTextDocument);
+  csr.movePosition(QTextCursor::Start);
+  int iindx = 0;
+  while( !(csr = mTextDocument->find("<video></video>",csr)).isNull() ) {
+      //qDebug() << "emitting @ " << csr.position();
+      emit addAnnotation(annots[iindx++],pos,pos);
+      csr.movePosition(QTextCursor::NextWord);
+  }
+
   // handle toc
   struct titerator *tit;

diff --git a/generators/epub/epubdocument.cpp b/generators/epub/epubdocument.cpp
index 94b5017..0f7f734 100644
--- a/generators/epub/epubdocument.cpp
+++ b/generators/epub/epubdocument.cpp
@@ -9,6 +9,7 @@

 #include "epubdocument.h"
 #include <QRegExp>
+#include <QDebug>

 using namespace Epub;

@@ -138,6 +139,11 @@ QVariant EpubDocument::loadResource(int type, const QUrl &name)
       resource.setValue(css);
       break;
     }
+    case QTextDocument::UserResource: {
+        QByteArray arr = QByteArray::fromRawData(data,size);
+        resource.setValue(arr);
+        break;
+    }
     default:
       resource.setValue(QString::fromUtf8(data));
       break;
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index 16b00ab..217297a 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -902,7 +902,10 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
             {
                 Okular::MovieAnnotation * movieAnn = static_cast< Okular::MovieAnnotation * >( a );
                 VideoWidget * vw = new VideoWidget( movieAnn, movieAnn->movie(), d->document, viewport() );
+                vw->setFixedSize(movieAnn->movie()->size());
                 item->videoWidgets().insert( movieAnn->movie(), vw );
+
+                qDebug() << vw->geometry();
                 vw->pageInitialized();
             }
             else if ( a->subType() == Okular::Annotation::AScreen )
