Recent

Author Topic: [SOLVED] Grab images from video  (Read 5129 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
[SOLVED] Grab images from video
« 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.
« Last Edit: May 25, 2021, 05:52:09 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

BlueIcaro

  • Hero Member
  • *****
  • Posts: 793
    • Blog personal
Re: Grab images from video
« Reply #1 on: May 25, 2021, 12:36:04 pm »
The source of the video is camera or a file?

/BlueIcaro

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Grab images from video
« Reply #2 on: May 25, 2021, 01:29:49 pm »
File
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Grab images from video
« Reply #3 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
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Grab images from video
« Reply #4 on: May 25, 2021, 05:30:45 pm »
you have also paslibvlc

see attachments
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Grab images from video
« Reply #5 on: May 25, 2021, 05:50:42 pm »
Thanks. I don't like VLC, but I did the same thing with MPV.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Zvoni

  • Hero Member
  • *****
  • Posts: 2329
Re: [SOLVED] Grab images from video
« Reply #6 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
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: [SOLVED] Grab images from video
« Reply #7 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.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: [SOLVED] Grab images from video
« Reply #8 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 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
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: [SOLVED] Grab images from video
« Reply #9 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.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

 

TinyPortal © 2005-2018