Recent

Author Topic: AVI to BMP extraction  (Read 6017 times)

kamassito

  • Newbie
  • Posts: 1
AVI to BMP extraction
« on: August 01, 2016, 02:24:04 pm »
Hello,

Does anybody know the easiest way how to extract bmp frames from avi in Lazarus. I want to know how to read   information from videostream (from the texture) into twodimensional array of byte where the array will represent bmp texture without bitmap header. Thank you.

mercury

  • Full Member
  • ***
  • Posts: 154
Re: AVI to BMP extraction
« Reply #1 on: September 28, 2016, 05:33:56 am »
Take a look my LibFFPlay -> http://forum.lazarus.freepascal.org/index.php/topic,33105.0.html
Modify the Cb_display function to fit your propose.
Notice: LibFFPlay is a player, it decodes real-time. If you want dump all frames in a video file, it will take time same as the video length.

Or you can directly deal with FFmpeg -> http://www.delphiffmpeg.com/headers/
Maybe you can find something in this example -> ffmpeg-delphi-pascal-headers-2.6.4.zip\examples\filtering_video.dpr

metis

  • Sr. Member
  • ****
  • Posts: 300
Re: AVI to BMP extraction
« Reply #2 on: December 03, 2018, 02:13:49 pm »
@kamassito

At least the easiest Way to save VideoFrames to ImageFiles - with a little Help of FFmpeg's 'ffmpeg.exe' CommandLine Tool - is here:
http://forum.lazarus.freepascal.org/index.php/topic,43411.0.html
-> GoTo "[Grab]+[-i "grabbed.mkv" -map v frame%08d.png] will save the File's VideoFrames to PNG-ImageFiles.".

In Your Case, write  -i "videofile.avi" -map v frame%08d.bmp  into the first Line of 'RunFFmpeg' and click [Grab].

If You want to obtain the VideoFrames themselves and furthermore as fast as possible, there is no easy Way.
You have to open/read/close the VideoFile by Yourself.

The Dranger-Tutorial explains very well how to do it with C and FFmpeg-Libraries:
http://dranger.com/ffmpeg/.
For how to read out FrameData, see
'Tutorial 01: Making Screencaps' -> GoTo: "the SaveFrame function" -> "Write pixel data".
For how to assign FrameData to BMP, see
'Tutorial 04: Spawning Threads' -> GoTo "copy the frame into the overlay" -> "/* point pict at the queue */.

For how to read out FrameData with FPC, see e.g.
attached 'mpegpas02.zip' -> 'mpegpas02\PacketRead5.pas' -> procedure 'SaveFrame()' -> "Write pixel data".
For how to assign FrameData to BMP with FPC, see here
http://forum.lazarus.freepascal.org/index.php/topic,26666.msg196377.html#msg196377
-> Dnload attached 'DrangerTutorial08.c2FPC.lpr.zip' and GoTo "//* point pict at the queue */".

 :)
« Last Edit: December 05, 2018, 03:34:45 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

 

TinyPortal © 2005-2018