extract a thumbnail of a given frame from a video

540 views
Skip to first unread message

ledzgio

unread,
Dec 5, 2013, 6:40:31 AM12/5/13
to xuggle...@googlegroups.com
Hello,

I have an mp4 video and I have to extract a thumbnail image of a specific frame of the video.

How can I do that?

thanks

Michal Skála

unread,
Dec 5, 2013, 8:12:06 AM12/5/13
to xuggle...@googlegroups.com
Hi, try this:

        public static void main(String[] args)
{
IMediaReader reader = ToolFactory.makeReader("g://mp4.mp4");
reader.addListener(new VideoPictureListener());
reader.open();
while (reader.readPacket() == null)
{}
}
private static class VideoPictureListener extends MediaToolAdapter
{
@Override
public void onVideoPicture(IVideoPictureEvent event)
{
super.onVideoPicture(event);
if (event.getTimeStamp() == 1000)
{
IVideoPicture pict = event.getMediaData();  // get the VideoPicture
                            BufferedImage image = event.getImage();   // get the image
                        }
}
}

Michal


--
You received this message because you are subscribed to the Google Groups "xuggler-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xuggler-user...@googlegroups.com.
To post to this group, send email to xuggle...@googlegroups.com.
Visit this group at http://groups.google.com/group/xuggler-users.
For more options, visit https://groups.google.com/groups/opt_out.

ledzgio

unread,
Dec 5, 2013, 8:50:26 AM12/5/13
to xuggle...@googlegroups.com
Thanks.

If I understand well with event.getTimeStamp() I can seek the video and capture single images, but event.getTimeStamp() is in nanoseconds, how can I convert to frames unit?

Michal Skála

unread,
Dec 5, 2013, 9:02:54 AM12/5/13
to xuggle...@googlegroups.com

ledzgio

unread,
Dec 5, 2013, 9:39:29 AM12/5/13
to xuggle...@googlegroups.com
I don't understand exactly how to manage frames...my video is 25 frame per seconds.

I tried event.getTimeStamp()/1000 which should give me the current frame...I am right?


Il giorno giovedì 5 dicembre 2013 12:40:31 UTC+1, ledzgio ha scritto:

ledzgio

unread,
Dec 5, 2013, 10:29:28 AM12/5/13
to xuggle...@googlegroups.com
There is also another problem, is the video has lot of frames, it will takes lot of time to get the latest frames...is there a way to jump to a frame?


Il giorno giovedì 5 dicembre 2013 12:40:31 UTC+1, ledzgio ha scritto:

Michal Skála

unread,
Dec 6, 2013, 1:34:05 AM12/6/13
to xuggle...@googlegroups.com
Well, it's not possible with the MediaTool API I think, you could try to listen for the onReadPacket event, I guess in this case is the video picture not decoded and it should be a bit faster. But then you'll need to decode the picture by yourself.

Or you can go with the advanced API, some examples here: https://github.com/artclarke/xuggle-xuggler/tree/master/src/com/xuggle/xuggler/demos

Or, you can play with the MP4 file and read movie atoms ;)

Michal


--
Reply all
Reply to author
Forward
0 new messages