Skip to content

Commit

Permalink
Fixed saving large movies into annoations viewport.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Feb 26, 2024
1 parent 647dd4d commit 2cc1324
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 32 deletions.
5 changes: 4 additions & 1 deletion mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ v1.0.7
as I was using an NTFS drive which sets umask 0022 by default.
- Made reading session more robust to handle missing files or wrong settings.
- Made checking for readable files faster.

- Fixed saving large images/movies with annotations on work properly.
- Improved memory consumption of saving movies, particularly large ones like
4K.


v1.0.6
======
Expand Down
79 changes: 48 additions & 31 deletions mrv2/lib/mrvFl/mrvSaveMovie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ namespace mrv
auto mute = player->isMuted();
player->setMute(true);


auto context = ui->app->getContext();

// Get I/O cache and store its size.
auto ioSystem = context->getSystem<io::System>();
auto cache = ioSystem->getCache();

size_t oldCacheSize = cache->getMax();


try
{

Expand Down Expand Up @@ -117,8 +127,12 @@ namespace mrv
ioOptions["OpenEXR/DWACompressionLevel"] = s.str();
}
#endif


auto context = ui->app->getContext();
// Make I/O cache be 1Gb to deal with long movies fine.
size_t bytes = memory::gigabyte;
cache->setMax(bytes);

auto timeline = player->timeline();

auto startTimeOpt = timeline->getTimeline()->global_start_time();
Expand Down Expand Up @@ -241,8 +255,7 @@ namespace mrv
offscreenBufferOptions.colorType = image::PixelType::RGBA_F32;

// Create the writer.
auto writerPlugin =
context->getSystem<io::System>()->getPlugin(path);
auto writerPlugin = ioSystem->getPlugin(path);

if (!writerPlugin)
{
Expand All @@ -267,34 +280,7 @@ namespace mrv
.arg(outputInfo.size)
.arg(outputInfo.pixelType);
LOG_INFO(msg);

outputInfo = writerPlugin->getWriteInfo(outputInfo);
if (image::PixelType::None == outputInfo.pixelType)
{
outputInfo.pixelType = image::PixelType::RGB_U8;
offscreenBufferOptions.colorType = image::PixelType::RGB_U8;
#ifdef TLRENDER_EXR
if (saveEXR)
{
offscreenBufferOptions.colorType =
image::PixelType::RGB_F32;
}
#endif
}

#ifdef TLRENDER_EXR
if (saveEXR)
{
outputInfo.pixelType = options.exrPixelType;
}
#endif
if (saveHDR)
{
outputInfo.pixelType = image::PixelType::RGB_F32;
offscreenBufferOptions.colorType =
image::PixelType::RGB_F32;
}


if (annotations)
{
view->setActionMode(ActionMode::kScrub);
Expand Down Expand Up @@ -323,6 +309,7 @@ namespace mrv
view->frameView();
renderSize.w = viewportSize.w;
renderSize.h = viewportSize.h;
outputInfo.size = renderSize;
LOG_WARNING(_("Image too big. "
"Will save the viewport size."));
}
Expand All @@ -341,6 +328,34 @@ namespace mrv
LOG_INFO(msg);
}

outputInfo = writerPlugin->getWriteInfo(outputInfo);
if (image::PixelType::None == outputInfo.pixelType)
{
outputInfo.pixelType = image::PixelType::RGB_U8;
offscreenBufferOptions.colorType = image::PixelType::RGB_U8;
#ifdef TLRENDER_EXR
if (saveEXR)
{
offscreenBufferOptions.colorType =
image::PixelType::RGB_F32;
}
#endif
}

#ifdef TLRENDER_EXR
if (saveEXR)
{
outputInfo.pixelType = options.exrPixelType;
}
#endif
if (saveHDR)
{
outputInfo.pixelType = image::PixelType::RGB_F32;
offscreenBufferOptions.colorType =
image::PixelType::RGB_F32;
}


msg = tl::string::Format(_("Output info: {0} {1}"))
.arg(outputInfo.size)
.arg(outputInfo.pixelType);
Expand Down Expand Up @@ -657,6 +672,8 @@ namespace mrv
settings->addRecentFile(file);
ui->uiMain->fill_menu(ui->uiMenuBar);
}

cache->setMax(oldCacheSize);
}

} // namespace mrv

0 comments on commit 2cc1324

Please sign in to comment.