Lazarus

Programming => Graphics and Multimedia => Audio and Video => Topic started by: pcurtis on May 25, 2021, 11:05:19 am

Title: [SOLVED] Grab images from video
Post by: pcurtis on May 25, 2021, 11:05:19 am
How can I grab images from a video clip at random positions?

For example I have a clip of 600 seconds. I want to grab images after 10, 90, 300 and 550 seconds.
Title: Re: Grab images from video
Post by: BlueIcaro on May 25, 2021, 12:36:04 pm
The source of the video is camera or a file?

/BlueIcaro
Title: Re: Grab images from video
Post by: pcurtis on May 25, 2021, 01:29:49 pm
File
Title: Re: Grab images from video
Post by: Jurassic Pork on May 25, 2021, 01:44:27 pm
hello,
for example use lazvlc to use vlc as video reader. And use the position and snapshot functions to capture a video frame at a particular time.
Friendly, J.P
Title: Re: Grab images from video
Post by: Jurassic Pork on May 25, 2021, 05:30:45 pm
you have also paslibvlc

see attachments
Title: Re: Grab images from video
Post by: pcurtis on May 25, 2021, 05:50:42 pm
Thanks. I don't like VLC, but I did the same thing with MPV.
Title: Re: [SOLVED] Grab images from video
Post by: Zvoni on May 26, 2021, 08:50:33 am
You could use the ffmpeg library.
I think i have a snippet somewhere, where i fire up ffmpeg in a TProcess, extracting jpeg's from a video-file incl seeking to specific time-positions
Title: Re: [SOLVED] Grab images from video
Post by: pcurtis on May 26, 2021, 10:01:21 am
If you have it I would like a look. I tried ffmpeg, but it was slow (probably due to my incorrect use) where it started to seek from 0 to the required frame. Doing this for each image.
Title: Re: [SOLVED] Grab images from video
Post by: Jurassic Pork on May 26, 2021, 10:44:29 am
hello,
If you have it I would like a look. I tried ffmpeg, but it was slow (probably due to my incorrect use) where it started to seek from 0 to the required frame. Doing this for each image.

you can try the RunFFmpeg Demo project  from here (https://forum.lazarus.freepascal.org/index.php/topic,43411.msg303762.html#msg303762) in the zip file FFGrab4Laz_01.7z read instructions to install ffmpeg for that.
change the grab command to what you want.
For example to extract the frame at 10 seconds in my mp4 file Bear in the Woods :
Quote
-ss 00:00:10 -i "D:\temp\Bear In The Woods.mp4" -vframes 1 -q:v 2 screenhot.jpg

Friendly, J.P
Title: Re: [SOLVED] Grab images from video
Post by: pcurtis on May 26, 2021, 12:31:29 pm
Now I remember why I stopped using ffmpeg.

I couldn't figure out how to pass a list of unevenly spaced times to grab.
TinyPortal © 2005-2018