Index: Source/Plugins/Plugin_VideoDX9/Src/Render.cpp
===================================================================
--- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp	(revision 7095)
+++ Source/Plugins/Plugin_VideoDX9/Src/Render.cpp	(working copy)
@@ -920,6 +920,8 @@
 // This function has the final picture. We adjust the aspect ratio here.
 void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc,float Gamma)
 {
+	static char* data = 0;
+	static int w = 0, h = 0;
 	if (g_bSkipCurrentFrame || (!XFBWrited && (!g_ActiveConfig.bUseXFB || !g_ActiveConfig.bUseRealXFB)) || !fbWidth || !fbHeight)
 	{
 		Core::Callback_VideoCopiedToXFB(false);
@@ -1120,10 +1122,15 @@
 			D3DLOCKED_RECT rect;
 			if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, dst_rect.AsRECT(), D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
 			{
-				char* data = (char*)malloc(3 * s_recordWidth * s_recordHeight);
+				if (!data || w != s_recordWidth || h != s_recordHeight)
+				{
+					free(data);
+					data = (char*)malloc(3 * s_recordWidth * s_recordHeight);
+					w = s_recordWidth;
+					h = s_recordHeight;
+				}
 				formatBufferDump((const char*)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch);
 				AVIDump::AddFrame(data);
-				free(data);
 				ScreenShootMEMSurface->UnlockRect();
 			}
 		}
@@ -1133,6 +1140,12 @@
 	{
 		if (s_bLastFrameDumped && s_bAVIDumping)
 		{
+			if (data)
+			{
+				free(data);
+				data = 0;
+				w = h = 0;
+			}
 			AVIDump::Stop();
 			s_bAVIDumping = false;
 			OSD::AddMessage("Stop dumping frames to AVI", 2000);
Index: Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
===================================================================
--- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp	(revision 7095)
+++ Source/Plugins/Plugin_VideoOGL/Src/Render.cpp	(working copy)
@@ -961,8 +961,16 @@
 // This function has the final picture. We adjust the aspect ratio here.
 void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc,float Gamma)
 {
+	static u8 *data = 0;
+	static int w = 0, h = 0;
 	if (g_bSkipCurrentFrame || (!XFBWrited && (!g_ActiveConfig.bUseXFB || !g_ActiveConfig.bUseRealXFB)) || !fbWidth || !fbHeight)
 	{
+		if (g_ActiveConfig.bDumpFrames && data)
+		#ifdef _WIN32
+			AVIDump::AddFrame((char *) data);
+		#else
+			AVIDump::AddFrame(data);
+		#endif
 		Core::Callback_VideoCopiedToXFB(false);
 		return;
 	}
@@ -975,6 +983,12 @@
 	const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
 	if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
 	{
+		if (g_ActiveConfig.bDumpFrames && data)
+		#ifdef _WIN32
+			AVIDump::AddFrame((char *) data);
+		#else
+			AVIDump::AddFrame(data);
+		#endif
 		Core::Callback_VideoCopiedToXFB(false);
 		return;
 	}
@@ -1134,9 +1148,14 @@
 	if (g_ActiveConfig.bDumpFrames)
 	{
 		s_criticalScreenshot.Enter();
-		int w = dst_rect.GetWidth();
-		int h = dst_rect.GetHeight();
-		u8 *data = new u8[3 * w * h];
+		if (!data || w != dst_rect.GetWidth() ||
+		             h != dst_rect.GetHeight())
+		{
+			if (data) delete[] data;
+			w = dst_rect.GetWidth();
+			h = dst_rect.GetHeight();
+			data = new u8[3 * w * h];
+		}
 		glPixelStorei(GL_PACK_ALIGNMENT, 1);
 		glReadPixels(dst_rect.left, dst_rect.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, data);
 		if (GL_REPORT_ERROR() == GL_NO_ERROR && w > 0 && h > 0)
@@ -1172,13 +1191,18 @@
 		else
 			NOTICE_LOG(VIDEO, "Error reading framebuffer");
 
-		delete[] data;
 		s_criticalScreenshot.Leave();
 	}
 	else
 	{
 		if (s_bLastFrameDumped && s_bAVIDumping)
 		{
+			if (data)
+			{
+				delete[] data;
+				data = 0;
+				w = h = 0;
+			}
 			AVIDump::Stop();
 			s_bAVIDumping = false;
 			OSD::AddMessage("Stop dumping frames", 2000);
Index: Source/Core/VideoCommon/Src/AVIDump.cpp
===================================================================
--- Source/Core/VideoCommon/Src/AVIDump.cpp	(revision 7095)
+++ Source/Core/VideoCommon/Src/AVIDump.cpp	(working copy)
@@ -30,6 +30,8 @@
 #include "CommonPaths.h"
 #include "Log.h"
 
+#include "HW/VideoInterface.h" //for TargetRefreshRate
+
 HWND m_emuWnd;
 LONG m_byteBuffer;
 LONG m_frameCount;
@@ -189,8 +191,7 @@
 	memset(&m_header, 0, sizeof(m_header));
 	m_header.fccType = streamtypeVIDEO;
 	m_header.dwScale = 1;
-	// TODO: Decect FPS using NTSC/PAL
-	m_header.dwRate = 60;
+	m_header.dwRate = VideoInterface::TargetRefreshRate;
 	m_header.dwSuggestedBufferSize  = m_bitmap.biSizeImage;
 
 	return SUCCEEDED(AVIFileCreateStream(m_file, &m_stream, &m_header));
@@ -202,6 +203,8 @@
 #include "StringUtil.h"
 #include "Log.h"
 
+#include "HW/VideoInterface.h" //for TargetRefreshRate
+
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
@@ -258,7 +261,7 @@
 	s_Stream->codec->bit_rate = 400000;
 	s_Stream->codec->width = s_width;
 	s_Stream->codec->height = s_height;
-	s_Stream->codec->time_base = (AVRational){1, 30};
+	s_Stream->codec->time_base = (AVRational){1, VideoInterface::TargetRefreshRate};
 	s_Stream->codec->gop_size = 12;
 	s_Stream->codec->pix_fmt = PIX_FMT_YUV420P;
 
