Related: tdf#149971 svx: support explicitly provided snapshots for media shapes

Snapshots / previews for media objects are used when the shape's video
is not playing. This is generated by seeking to the 3rd second in the
video, probably to avoid initial black frames.

The trouble is that PowerPoint takes the initial frame (at least in case
of the bugdoc), so our snapshot doesn't match the reference.

We already import a bitmap snapshot from PPTX files since commit
e2d46da076 (avmedia: add doc model for
bitmap fill of slide narrations, 2021-01-21), fix the problem by
changing the snapshot generation to prefer this bitmap over generating
one from the video.

The crop properties of this bitmap / the video are still not yet handled
from PPTX.

Change-Id: Id985eaaaad5e4222d9a98203d054e08a0f97a0f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138763
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna 2022-08-24 13:53:38 +02:00
parent 87de096032
commit 8fa1d453c9
3 changed files with 32 additions and 0 deletions

Binary file not shown.

View file

@ -36,6 +36,7 @@
#include <comphelper/propertyvalue.hxx>
#include <sfx2/viewsh.hxx>
#include <svl/itempool.hxx>
#include <svx/svdomedia.hxx>
#include <sdr/contact/objectcontactofobjlistpainter.hxx>
@ -483,6 +484,28 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testMaterialSpecular)
// The first light is harsh, the second light soft. So the 3D scene should have 6 lights (1+1+4).
assertXPath(pXmlDoc, "//light", 6);
}
CPPUNIT_TEST_FIXTURE(SvdrawTest, testVideoSnapshot)
{
// Given a slide with a media shape, containing a 4 sec video, red-green-blue-black being the 4
// seconds:
OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/video-snapshot.pptx");
mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument");
SdrPage* pSdrPage = getFirstDrawPageWithAssert();
auto pSdrMediaObj = dynamic_cast<SdrMediaObj*>(pSdrPage->GetObj(0));
// When getting the red snapshot of the video:
Graphic aSnapshot(pSdrMediaObj->getSnapshot());
// Then make sure the color is correct:
const BitmapEx& rBitmap = aSnapshot.GetBitmapExRef();
// Without the accompanying fix in place, this test would have failed with:
// - Expected: rgba[ff0000ff]
// - Actual : rgba[000000ff]
// i.e. the preview was black, not red; since we seeked 3 secs into the video, while PowerPoint
// doesn't do that.
CPPUNIT_ASSERT_EQUAL(Color(0xff, 0x0, 0x0), rBitmap.GetPixelColor(0, 0));
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -151,6 +151,15 @@ uno::Reference< graphic::XGraphic > const & SdrMediaObj::getSnapshot() const
#if HAVE_FEATURE_AVMEDIA
if( !m_xImpl->m_xCachedSnapshot.is() )
{
Graphic aGraphic = m_xImpl->m_MediaProperties.getGraphic();
if (!aGraphic.IsNone())
{
// We have an explicit graphic for this media object, then go with that instead of
// generating our own one.
m_xImpl->m_xCachedSnapshot = aGraphic.GetXGraphic();
return m_xImpl->m_xCachedSnapshot;
}
OUString aRealURL = m_xImpl->m_MediaProperties.getTempURL();
if( aRealURL.isEmpty() )
aRealURL = m_xImpl->m_MediaProperties.getURL();