Recent

Author Topic: jpg images to video  (Read 4431 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
jpg images to video
« on: December 11, 2018, 12:01:17 pm »
Hi guys, I was wondering if anyone has an example of how to make a video from a series of jpg images. For example I have 100 jpg images and I want them to become a video (assuming that those images were taken with a frequency of 100 milliseconds.
A cross platform procedure would be necessary.
Thanks for your help
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

correa.elias

  • New Member
  • *
  • Posts: 18
Re: jpg images to video
« Reply #1 on: December 11, 2018, 12:54:15 pm »
You can call ffmpeg using TProcess from your pascal program.

metis

  • Sr. Member
  • ****
  • Posts: 300
Re: jpg images to video
« Reply #2 on: December 12, 2018, 05:08:25 pm »
@xinyiman

Quote
You can call ffmpeg using TProcess...
If You need it a bit more detailed, see FFGrab4Laz
-> GoTo: 'RunFFmpeg'.

For how to build the FFmpeg-CommandLine, see the FFmpeg Documentation
-> GoTo: "You can extract images from a video, or create a video from many images"
                 -> "For extracting images from a video" and "For creating a video from many images".

E.g. to extract Images from a Video, and then recreate that Video from those Images,
copy the following CommandLines into the first Line of 'RunFFmpeg' and click [Grab].

Video -> Images:
-i "tmp/Video2Image.avi" -f image2 tmp/frame%03d.jpg

Images -> Video:
-f image2 -framerate 12 -i tmp/frame%03d.jpg "tmp/Image2Video.avi"

'FFmpeg' is cross platform; the SourceCode of 'RunFFmpeg' is currently Windows, but You may extend it with Linux and Mac - it's OpenSource.

:)
« Last Edit: May 04, 2024, 12:15:04 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 296
Re: jpg images to video
« Reply #3 on: April 29, 2024, 08:47:42 am »
Not to open new topic ....

Code: Pascal  [Select][+][-]
  1.      AProcess:= TProcess.Create(nil);
  2.      Aprocess.Executable:= AppPath + 'ffmpeg.exe';
  3.      Aprocess.Parameters.Add('-i Images1/inputImage%d.bmp');
  4.      Aprocess.Parameters.Add('-framerate 1');
  5.      Aprocess.Parameters.Add('-c:v libx264');
  6.      Aprocess.Parameters.Add('-r 30 output.mp4');
  7.      Aprocess.Parameters.Add('-y'); //overwrite output files
  8.      AProcess.Execute;
  9.      AProcess.Free;    
  10.  

Not sure where 'output.mp4' should be, there or somewhere else ?


lazarus 3.2-fpc-3.2.2-win32/win64

TRon

  • Hero Member
  • *****
  • Posts: 3141
Re: jpg images to video
« Reply #4 on: April 29, 2024, 11:09:28 am »
Not sure where 'output.mp4' should be, there or somewhere else ?
Each option requires its own (individual) addition to the parameter-list of TProcess.
All software is open source (as long as you can read assembler)

Zvoni

  • Hero Member
  • *****
  • Posts: 2620
Re: jpg images to video
« Reply #5 on: April 29, 2024, 01:33:55 pm »
Not sure where 'output.mp4' should be, there or somewhere else ?
Each option requires its own (individual) addition to the parameter-list of TProcess.
Yes, and he has the "output.mp4" in his Line 6.

That said: I looked at the ffmpeg-docs, and contrary to the "-i"-Switch, which defines the "Input-URL", there is (seems to be) no "-o"-Switch defining an explicit outputfile (or i haven't found it), so at a guess, ffmpeg treats any (additional?) "filename", that is NOT behind a "-i"-switch as an output-file
« Last Edit: April 29, 2024, 01:35:29 pm by Zvoni »
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

cdbc

  • Hero Member
  • *****
  • Posts: 1497
    • http://www.cdbc.dk
Re: jpg images to video
« Reply #6 on: April 29, 2024, 02:27:45 pm »
Hi
Quote
so at a guess, ffmpeg treats any (additional?) "filename", that is NOT behind a "-i"-switch as an output-file
Yes it does ...and bases it's output format on the extension provided e.g.:
 ffmpeg -i "Lynyrd Skynyrd - Simple Man - Live At The Florida Theatre ⧸ 2015 (Official Video) [Mqfwbf3X8SA].webm" lynyrd-skynyrd.wav

Produces the soundtrack from that music-video...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

 

TinyPortal © 2005-2018