After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 697986 - Could not take screenshot: failed to retrieve or convert video frame
Could not take screenshot: failed to retrieve or convert video frame
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: dont know
1.x
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-04-14 10:31 UTC by Michael Monreal
Modified: 2017-07-13 21:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael Monreal 2013-04-14 10:31:08 UTC
When creating a gallery, the thumbnailer (totem 3.6.3) fails to take the last screenshot. On the gallery page, the last thumb is black. On the console I see:

Could not take screenshot: failed to retrieve or convert video frame

The timestamp shown for the last thumb is still part of the video.
Comment 1 Bastien Nocera 2013-04-15 10:27:41 UTC
It's supposed to take the screenshot just a little before the end of the video file, but it seems to fail when the index in the stream is too coarse. Using GST_SEEK_FLAG_ACCURATE for the seek might fix the problem.

Can you test this patch? Otherwise it'll have to wait until I can investigate more.

diff --git a/src/totem-video-thumbnailer.c b/src/totem-video-thumbnailer.c
index 48d5862..8ed1f2c 100644
--- a/src/totem-video-thumbnailer.c
+++ b/src/totem-video-thumbnailer.c
@@ -332,7 +332,7 @@ thumb_app_seek (ThumbApp *app,
                gint64    _time)
 {
        gst_element_seek (app->play, 1.0,
-                         GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
+                         GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
                          GST_SEEK_TYPE_SET, _time * GST_MSECOND,
                          GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
        /* And wait for this seek to complete */
Comment 2 Bastien Nocera 2013-04-17 16:06:36 UTC
That doesn't seem to be enough.

I can reproduce here with an MP4, WMV and MKV types.

Tim, ideas?
Comment 3 Bastien Nocera 2013-04-17 16:08:46 UTC
The reproducer is:
totem-video-thumbnailer -v -g 3 video.mov foo.png
Comment 4 Tim-Philipp Müller 2013-04-17 16:31:08 UTC
It looks like what happens is that the videosink gets a GAP event before it gets a video buffer, which makes it preroll, but then the snapshotter doesn't find a buffer of course. The GAP event is probably sent by the streamsynchronizer in playbin because the audio track went EOS already. Possibly a bug.

One thing to try would be to tell playbin not to render any audio at all, but getting the "flags" property and unsetting the audio flag.
Comment 5 Bastien Nocera 2013-04-17 23:07:16 UTC
It's totem-video-thumbnailer, not the player. I've disabled GST_PLAY_FLAG_AUDIO to leave GST_PLAY_FLAG_VIDEO as the only flags, and it doesn't make a difference. Setting a NULL audiosink instead of a fakesink also doesn't solve the problem.
Comment 6 Bastien Nocera 2013-08-24 03:13:40 UTC
Tim, any new ideas about this problem?
Comment 7 Nicolas Dufresne (ndufresne) 2014-03-28 14:06:48 UTC
I think I read about a problem with seeking to the very last frame, don't we have this bug where we may reach EOS, even though seek is accurate ? Would be nice if the offending video can be made available.
Comment 8 Bastien Nocera 2014-03-28 14:45:16 UTC
(In reply to comment #7)
> I think I read about a problem with seeking to the very last frame, don't we
> have this bug where we may reach EOS, even though seek is accurate ? Would be
> nice if the offending video can be made available.

All the AVI and MP4 videos I tried on my system failed in the same way. MKV seemed to work.

Maybe a demuxer problem?
Comment 9 Nicolas Dufresne (ndufresne) 2014-03-28 15:21:29 UTC
(In reply to comment #8)
> All the AVI and MP4 videos I tried on my system failed in the same way. MKV
> seemed to work.
> 
> Maybe a demuxer problem?

Thanks, just didn't understand that from the initial problem. And is these seek accurate or not ?
Comment 10 Bastien Nocera 2014-03-28 15:49:58 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > All the AVI and MP4 videos I tried on my system failed in the same way. MKV
> > seemed to work.
> > 
> > Maybe a demuxer problem?
> 
> Thanks, just didn't understand that from the initial problem.

The last frame we seek to when creating a gallery in totem-video-thumbnailer fails to get captured. Reproducer's in comment 3.

> And is these seek accurate or not ?

"GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT" is what totem-video-thumbnailer uses right now.

Using "GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE" makes no difference, we still fail to capture the last frame of our gallery.

$ totem-video-thumbnailer -v -g 3 foo.avi foo.png
TotemVideoThumbnailer-Message: Initialised libraries, about to create video widget
TotemVideoThumbnailer-Message: setting URI file:///home/hadess/Projects/jhbuild/totem/src/foo.avi
TotemVideoThumbnailer-Message: Video widget created
TotemVideoThumbnailer-Message: About to open video file
TotemVideoThumbnailer-Message: Opened video file: 'foo.avi'
TotemVideoThumbnailer-Message: Producing gallery of 3 screenshots, taken at 2661946 millisecond intervals throughout a 7985840 millisecond-long stream.
TotemVideoThumbnailer-Message: Outputting as 1 rows and 3 columns.
TotemVideoThumbnailer-Message: Scaling each screenshot by 0.400000.
TotemVideoThumbnailer-Message: Created output pixbuf (816x118).
TotemVideoThumbnailer-Message: Composited screenshot from 2661946 milliseconds (address 274855472) at (12,5).
TotemVideoThumbnailer-Message: Composited screenshot from 5323892 milliseconds (address 39850384) at (280,5).

** (totem-video-thumbnailer:14619): WARNING **: Could not take screenshot: failed to retrieve or convert video frame

(totem-video-thumbnailer:14619): GdkPixbuf-CRITICAL **: gdk_pixbuf_composite: assertion 'GDK_IS_PIXBUF (src)' failed

(totem-video-thumbnailer:14619): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
TotemVideoThumbnailer-Message: Composited screenshot from 7985838 milliseconds (address 0) at (548,5).
TotemVideoThumbnailer-Message: Converting pixbuf to a Cairo surface.
TotemVideoThumbnailer-Message: Writing header text with Pango.
TotemVideoThumbnailer-Message: Writing screenshot timestamps with Pango.
TotemVideoThumbnailer-Message: Writing timestamp "44:21" at (230.880000,170.824000).
TotemVideoThumbnailer-Message: Writing timestamp "1:28:43" at (487.880000,170.824000).
TotemVideoThumbnailer-Message: Writing timestamp "2:13:05" at (755.880000,170.824000).
TotemVideoThumbnailer-Message: Converting Cairo surface back to pixbuf.
TotemVideoThumbnailer-Message: Saving captured screenshot
Comment 11 Tim-Philipp Müller 2017-07-13 21:40:22 UTC
This seems to work fine for me nowadays with the handful of (well-formatted/non-broken) MP4, MKV, AVI files I have tested.

Please re-open if it's still an issue, and/or make a sample file available please.