diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp
index 1bf0b0f2477873265e956ec8f48252f67e9fa343..87e1b91dda74a1caf2ea44baf107c3d0482e49f4 100644
--- a/source/App/DecoderApp/DecApp.cpp
+++ b/source/App/DecoderApp/DecApp.cpp
@@ -456,9 +456,10 @@ uint32_t DecApp::decode()
               msg(WARNING, "\nWarning: No frame rate info found in the bitstream, default 50 fps is used.\n");
             }
             const auto pps = pcListPic->front()->cs->pps;
-            m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].setOutputY4mInfo(
-              pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples(), frameRate, frameScale, m_outputBitDepth[0],
-              sps->getChromaFormatIdc());
+            auto confWindow = sps->getConformanceWindow();
+            const int picWidth = pps->getPicWidthInLumaSamples() - confWindow.getWindowLeftOffset() - confWindow.getWindowRightOffset();
+            const int picHeight = pps->getPicHeightInLumaSamples() - confWindow.getWindowTopOffset() - confWindow.getWindowBottomOffset();
+            m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].setOutputY4mInfo(picWidth, picHeight, frameRate, frameScale, m_outputBitDepth[0], sps->getChromaFormatIdc());
           }
           m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].open( reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
         }
diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp
index 83337ac1f399698beaa9b1d8ffeec63b0d286250..9c81dfd49f95ae9f4353fa1ff38c23516cec8d21 100644
--- a/source/App/EncoderApp/EncApp.cpp
+++ b/source/App/EncoderApp/EncApp.cpp
@@ -1432,8 +1432,8 @@ void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerId )
     }
     if (isY4mFileExt(reconFileName))
     {
-      m_cVideoIOYuvReconFile.setOutputY4mInfo(m_sourceWidth, m_sourceHeight, m_iFrameRate, 1, m_internalBitDepth[0],
-                                              m_chromaFormatIDC);
+      m_cVideoIOYuvReconFile.setOutputY4mInfo(m_sourceWidth - m_confWinLeft - m_confWinRight, 
+        m_sourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate, 1, m_internalBitDepth[0], m_chromaFormatIDC);
     }
     m_cVideoIOYuvReconFile.open( reconFileName, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth );  // write mode
   }