Having a problem trying to grab a snapshot of a movie to use as an icon
-
Hi All;
I've been looking on the web for a way to programatically open a video/movie file and grab a snapshot so i can use it for a thumbnail of the file in my app. I have found a few ways to do it on the web but none of them seem to work for me. I have tried using:
@ QPixmap image = QPixmap::grabWindow(tVideoWidget->winId());@
All i get is a black image. I have tried:
@QImage image = tVideoWidget->snapshot();@
With this i just get a null value for the image. Here is the method i have using to try to grab the frame:@QString Utilities::GrabSnapShot(QString aMoviePath, QWidget* aParent)
{
QString tPath = Utilities::AddThumbnailToPath(aMoviePath);
QString tThumbnailPath = RemoveExtension(tPath).append(THUMBNAIL_EXT);//get metadata information from the media file. Phonon::MediaObject* tMediaObject = new Phonon::MediaObject(aParent); Phonon::MediaSource* tMediaSource = new Phonon::MediaSource(aMoviePath); tMediaObject->clearQueue(); tMediaObject->enqueue(*tMediaSource); tMediaObject->seek(5000); tMediaObject->play(); // or setCurrentSource5.m_MediaObject->play(); Phonon::VideoWidget* tVideoWidget = new Phonon::VideoWidget(aParent); Phonon::createPath(tMediaObject, tVideoWidget); tVideoWidget->show(); QPixmap image = QPixmap::grabWindow(tVideoWidget->winId()); image.save(tThumbnailPath); delete tVideoWidget; delete tMediaSource; delete tMediaObject; return tThumbnailPath;
}@
From some of the posts i have seen it appears that these might be bugs. Is there another way of being able to grab the image/frame? thanks for any help.
-
not sure if you solved this old problem, but this post might help: "http://developer.qt.nokia.com/forums/viewthread/2487":http://developer.qt.nokia.com/forums/viewthread/2487