Skip to content

Commit

Permalink
Fixed saving movies of OTIO clips.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Sep 2, 2024
1 parent 6e9a8f6 commit 215723f
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 229 deletions.
3 changes: 3 additions & 0 deletions src/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ v1.2.6
- Added Portuguese, Italian and French translations done with AI.
- Added top bar OCIO / Color toggle (Hotkey 't' by default).
- Added lumma channel (Hotkey 'l' by default).
- Allowed saving .otio movie files as .mp4, .mov, etc. files. This allows
turning an .otio file into a new movie file. Useful when concatenating
movies with the Playlist panel or the -edl command-line switch.


v1.2.5
Expand Down
93 changes: 50 additions & 43 deletions src/lib/mrvFl/mrvSaveMovie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ namespace mrv
const bool hasVideo = !info.video.empty();

if (player->timeRange() != timeRange ||
info.videoTime.start_time() != timeRange.start_time())
info.videoTime.start_time() != timeRange.start_time() ||
info.videoTime.duration() != timeRange.duration())
{
double videoRate = info.videoTime.duration().rate();
videoTime = otime::TimeRange(
Expand Down Expand Up @@ -652,7 +653,7 @@ namespace mrv
size_t totalSamples = 0;
size_t currentSampleCount =
startTime.rescaled_to(sampleRate).value();

while (running)
{
context->tick();
Expand Down Expand Up @@ -770,66 +771,72 @@ namespace mrv
else
{
// Get the videoData
const auto videoData =
auto videoData =
timeline->getVideo(currentTime).future.get();

if (videoData.layers.empty() ||
!videoData.layers[0].image)
{
std::string err =
string::Format(
_("Empty video data at time {0}."))
string::Format(_("Empty video data at time "
"{0}. Repeating frame."))
.arg(currentTime);
LOG_ERROR(err);
LOG_WARNING(err);
}

// This refreshes the view window
if (interactive)
else
{
view->make_current();
view->currentVideoCallback({videoData});
view->flush();
}

// This refreshes the view window
if (interactive)
{
view->make_current();
view->currentVideoCallback({videoData});
view->flush();
}

// back to conventional pixel operation
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
// CHECK_GL;
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
// back to conventional pixel operation
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
// CHECK_GL;
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

if (interactive)
gl::initGLAD();
if (interactive)
gl::initGLAD();

// Render the video to an offscreen buffer.
gl::OffscreenBufferBinding binding(buffer);
{
locale::SetAndRestore saved;
render->begin(offscreenBufferSize);
render->setOCIOOptions(view->getOCIOOptions());
render->setLUTOptions(view->lutOptions());
render->drawVideo(
{videoData},
{math::Box2i(0, 0, renderSize.w, renderSize.h)},
{timeline::ImageOptions()},
{timeline::DisplayOptions()},
timeline::CompareOptions(),
ui->uiView->getBackgroundOptions());
render->end();
}
// Render the video to an offscreen buffer.
gl::OffscreenBufferBinding binding(buffer);
{
locale::SetAndRestore saved;
render->begin(offscreenBufferSize);
render->setOCIOOptions(view->getOCIOOptions());
render->setLUTOptions(view->lutOptions());
render->drawVideo(
{videoData},
{math::Box2i(0, 0, renderSize.w, renderSize.h)},
{timeline::ImageOptions()},
{timeline::DisplayOptions()},
timeline::CompareOptions(),
ui->uiView->getBackgroundOptions());
render->end();
}

glPixelStorei(
GL_PACK_ALIGNMENT, outputInfo.layout.alignment);
glPixelStorei(
GL_PACK_ALIGNMENT, outputInfo.layout.alignment);
#if defined(TLRENDER_API_GL_4_1)
glPixelStorei(
GL_PACK_SWAP_BYTES,
outputInfo.layout.endian != memory::getEndian());
glPixelStorei(
GL_PACK_SWAP_BYTES,
outputInfo.layout.endian != memory::getEndian());
#endif // TLRENDER_API_GL_4_1

glReadPixels(
0, 0, outputInfo.size.w, outputInfo.size.h, format,
type, outputImage->getData());
glReadPixels(
0, 0, outputInfo.size.w, outputInfo.size.h, format,
type, outputImage->getData());
}
}

if (videoTime.contains(currentTime))
{
writer->writeVideo(currentTime, outputImage);
}
}

if (hasVideo)
Expand Down
4 changes: 2 additions & 2 deletions src/po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -2816,8 +2816,8 @@ msgstr "OpenGL Info: {0}"
msgid "Saving... {0}"
msgstr "Speichern... {0}"

msgid "Empty video data at time {0}."
msgstr "Leere Videodaten zur Zeit {0}."
msgid "Empty video data at time {0}. Repeating frame."
msgstr "Leere Videodaten zur Zeit {0}. Wiederholungsbild."

msgid "Reading preferences from \"{0}{1}\"."
msgstr "Voreinstellungen von \"{0}{1}\" lesen."
Expand Down
Loading

0 comments on commit 215723f

Please sign in to comment.