Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 08, 2016, 11:57:28 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Convert sequence of images to video (with ffmpeg?)  (Read 9376 times)

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,721
    • View Profile
    • The Blog of Deozaan
    • Read more about this member.
    • Donate to Member
IDEA: Convert sequence of images to video (with ffmpeg?)
« on: January 12, 2015, 02:10:56 PM »
Hello,

Every so often I have a sequence of images that I'd like to convert into a video. This is usually a bunch of screenshots of me programming made into a timelapse video for the finished product but more recently I've been exploring the "Mandelverse" (aka 3D fractals) and have been making timelapses of my explorations in preparation of rendering frames of an image that I then also need to convert into a video with ffmpeg.

Here are some examples of the videos I've made
Timelapse of me making a game for LD31:



Timelapse of me exploring the Mandelverse:



3D Fractal animation (composed of many individually rendered frames)






I use a tool called Chronolapse to take the screenshots for my timelapses, and it has a feature to convert the screenshots into a video, but Chronolapse hasn't been updated in years so they're very low quality videos with outdated codecs and lots of compression artifacts.

I searched and found ffmpeg which has a fairly simple commandline arguments to convert the images to a high quality video. But I can never remember all the arguments and have to resort to my notes each time I want to make a video.

What I would like is a nice, simple little GUI that had these options preset for me, would remember what I last set them to, but also allow me to easily customize them. To give you an idea of what I'm talking about, here are my notes I refer to:

Quote
From: http://notes.theorbi...pse-with-ffmpeg.html

First rename all files so they are ordered consecutively. I named them all ss######.png using XnViewMP.
Then use ffmpeg to turn them into a video with the following command:

ffmpeg -r 60 -i ss%06d.png -s 1920x1200 -vcodec libx264 ld29.mp4

[The "ss%06d" means each filename starts with "ss" followed by 6 digits, so ss000001.png through (up to) ss999999.png]

So the command is like so:

ffmpeg -r [framerate] -i [images] -s [resolution] -vcodec libx264 [videofilename].mp4

What I want the program to do:

I would like the app to allow me to customize the following values:

  • the path to ffmpeg (with file browser would be nice)
  • the framerate
  • the filename pattern for the images
  • resolution (maybe this can just be taken/grabbed from the size of the images?)
  • output video filename (with output path--file browser here would be nice as well)

Basically everything above that is in square brackets, plus the path to ffmpeg. As I said before, I'd like it to remember my settings from the last time I ran it, since I'm unlikely to change the path to ffmpeg.

It seems fairly simple to me in theory, but maybe it's more work than I would think.

Optional bonus features:

Another bonus nice thing to have (but not necessary) would be to let me browse for the images, and have it automatically figure out the pattern based on one of the images in the sequence. So for instance, if I navigate to "someImage12345678.png" it will automatically figure out the pattern and set it as "someImage%08d.png" for me. But again, that's just a nicety. All I really need is some sort of example to remind me of the format, either as a tooltip or inline.

Yet an additional bonus feature would be a wizard to batch rename files so they are numbered consecutively. When rendering frames for the animation, the frames are already named appropriately, but when capturing screenshots for the timelapses, the images are named with the timestamp. The timestamp is of course chronologically ordered, but the format is something like "Capture_2015-01-12_13-06-28.png" which isn't quite as useful as "someImage00005.png" would be. If it could count the number of images in a directory, or let me select all the images, then automatically batch rename them with enough leading zeroes, and then when finished automatically fill the "filename pattern" entry box, that would be wonderful. But again, not needed.

Thanks in advance!

« Last Edit: January 12, 2015, 02:51:10 PM by Deozaan »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,475
    • View Profile
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #1 on: January 12, 2015, 04:48:50 PM »
Chronolapse appears to be written in Python - maybe someone here can checkout the source and add the extra video formats supported by a newer version of mencoder?

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #2 on: January 12, 2015, 10:35:19 PM »
May be a plugin to SC wouldn't be too hard either :)

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,606
    • View Profile
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #3 on: January 12, 2015, 11:55:50 PM »
not video, but I've used Wink for similar things in the past...

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,475
    • View Profile
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #4 on: January 13, 2015, 03:55:06 AM »
There's also the old VirtualDub.

Drop the first image on its window and it will load all the others in sequence (as long as they're the same dimensions), then if you go File->Save as AVI you'll end up with a RAW AVI at the default 10fps, (you can change it under Video->Frame rate - which you can convert to any other format required using a video converter.

You can resize the output using a resize filter under Video->Filters.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,475
    • View Profile
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #5 on: January 14, 2015, 05:21:08 AM »
Here's a program that may do what you want:

AnotherGUI - AnotherGUI is a graphical front-end for audio/video command line converter (such as ffmpeg/ffmbc).

2015-01-14 22_02_01.pngIDEA: Convert sequence of images to video (with ffmpeg?)

Download the preset I attached to this post and extract it somewhere, (it'll create a 10fps video that's 1280x720 and displays each image for 1 second).

Download v2.0.2beta and the appropriate x86/x64 version of SQLite via the links on the page.

Extract them into a directory, add the executables from the ffmpeg archive, (ffmpeg, ffprobe, ffplay).

When you first run AnotherGUI, answer No to the following:

2015-01-14 21_57_15.png

Click the Edit button:

2015-01-14 21_59_30.pngIDEA: Convert sequence of images to video (with ffmpeg?)

Then click the Import button, select the file 1280x720@1.xml (extracted from the attachment), hit Open, and then hit OK:

2015-01-14 22_00_08.pngIDEA: Convert sequence of images to video (with ffmpeg?)

Exit the program, then run it again, (the preset won't show up until the next time it's run):

2015-01-14 22_10_21.pngIDEA: Convert sequence of images to video (with ffmpeg?)

Rename your image files so that they're sequentially numbered, then you can either drag'n'drop the folder they're in on the Add an image sequence button or click the button and select one of the images, the appropriate job will be created:

2015-01-14 21_35_18.pngIDEA: Convert sequence of images to video (with ffmpeg?)

It will output to the source folder by default, or you can change it by hitting the button - otherwise hit the Go button.

The last command run is displayed and you can save it as a .bat file to run again if necessary:

2015-01-14 22_21_24.pngIDEA: Convert sequence of images to video (with ffmpeg?)

You can edit the preset if you want a different frame rate or size.
« Last Edit: January 14, 2015, 07:14:14 PM by 4wd »

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,721
    • View Profile
    • The Blog of Deozaan
    • Read more about this member.
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #6 on: January 14, 2015, 02:11:19 PM »
Thanks! I'll look into this.

Download the preset I attached to this post and extract it somewhere, (it'll create a 10fps video that's 1280x720 and displays each image for 1 second).
Wouldn't that be a 1fps video if it only shows one frame (image) per second?  :huh:


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,475
    • View Profile
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #7 on: January 14, 2015, 06:27:02 PM »
Thanks! I'll look into this.

Download the preset I attached to this post and extract it somewhere, (it'll create a 10fps video that's 1280x720 and displays each image for 1 second).
Wouldn't that be a 1fps video if it only shows one frame (image) per second?  :huh:

No, video frame rate and image persistence are two different things.

Some video players, (I'm referring to software not a hardware media player, they're probably even more restricted), can't handle very low video frame rates, (I saw mentioned somewhere that VLC doesn't handle below around 10fps - I know MPC-BE doesn't like low rates).

To get an image to display for x seconds, ffmpeg creates x * fps copies of the image to display, so for the above preset: 1 (second) x 10 (fps) = 10 copies

10 fps means each frame is displayed for 100ms, so each of the 10 copies of the image is displayed for 100ms - appended together gives you each image being displayed in the video for 1 second.

Here's a page regarding ffmpeg, frame rates, and image sequences: Create a video slideshow from images

I've also added the -pix_fmt yuv420p mentioned on that page, (ensures maximum compatibility in final video with players/online sites).

In your original command:

Quote
ffmpeg -r [framerate] -i [images] -s [resolution] -vcodec libx264 [videofilename].mp4

Because you haven't specified a frame rate for the output video, the input image frame rate would be used - if this is too low, the video won't display correctly (ie. some images may appear for longer - I was getting the first image being displayed for 5 seconds and the following for 1 second) - if it's too high, the images might just flash up on screen or possibly they'll be dropped altogether from the final video.

BTW, if the folder you drop onto the interface button contains more than one image sequence, in theory it should create a job for each ... but I haven't tested that.

If you let me know what fps/dimensions/codecs you're interested in, I'll try knocking up some presets so you can look at them - specify image persistence in seconds and video output frame rate.

EDIT: I incorrectly made the description on the preset, (shows up under preset), as 1fps - forgot to change it after I'd finished playing around.  I've corrected and re-attached to the above post.


Addendum: I've attached some more presets you can import, (remember to restart program after importing), it should give you an idea of what to do:

Output video presets, (all MPEG4-AVC, MP4 format):
720x400, 2 images/s, 24fps  (2 images every second)
720x400, 5 images/s, 30fps  (5 images every second)
1280x720, 1image/s, 10fps  (1 image every second)
1280x720, 1image/s, 24fps  (1 image every second)
1280x720, 1image/5s, 24fps  (1 image every 5 seconds)
1280x720, 2images/s, 24fps  (2 images every second)
1980x1080, 2images/s, 24fps  (2 images every second)

Code: Text [Select]
  1. <?xml version="1.0" encoding="utf-16"?>
  2. <AnotherGUI_Presets_ver.03>
  3.         <Preset>
  4.                 <UUID>66a5159b-4405-499f-9b56-0439ae54978a</UUID>
  5.                 <Executable>ffmpeg.exe</Executable>
  6.                 <Name>Image sequence to video 1280x720, 1ips, 10fps</Name>
  7.                 <Description><![CDATA[Convert sequence of images to video (1280x720, 1 image/s, 10fps)]]></Description>
  8.                 <Category><![CDATA[IMAGES 1280]]></Category>
  9.                 <Arguments><![CDATA[-r 1
  10. -i "<FullSourceFileName>"
  11. -s 1280x720
  12. -r 10
  13. -vcodec libx264
  14. -pix_fmt yuv420p
  15. "<OutputPath><OutputFileName>.mp4"]]></Arguments>
  16.                 <Arguments2><![CDATA[]]></Arguments2>
  17.                 <Postprocess><![CDATA[]]></Postprocess>
  18.         </Preset>
  19.         <Preset>
  20.                 <UUID>808b659a-5bcf-4d87-8e17-789e995e167e</UUID>
  21.                 <Executable>ffmpeg.exe</Executable>
  22.                 <Name>Image sequence to video 1280x720, 1ips, 24fps</Name>
  23.                 <Description><![CDATA[Convert sequence of images to video (1280x720, 1 image/s, 24fps)]]></Description>
  24.                 <Category><![CDATA[IMAGES 1280]]></Category>
  25.                 <Arguments><![CDATA[-r 1
  26. -i "<FullSourceFileName>"
  27. -s 1280x720
  28. -r 24
  29. -vcodec libx264
  30. -pix_fmt yuv420p
  31. "<OutputPath><OutputFileName>.mp4"]]></Arguments>
  32.                 <Arguments2><![CDATA[]]></Arguments2>
  33.                 <Postprocess><![CDATA[]]></Postprocess>
  34.         </Preset>
  35.         <Preset>
  36.                 <UUID>90f8f618-766b-4a16-91e9-04eb67e7ba45</UUID>
  37.                 <Executable>ffmpeg.exe</Executable>
  38.                 <Name>Image sequence to video 1280x720, 2ips, 24fps</Name>
  39.                 <Description><![CDATA[Convert sequence of images to video (1280x720, 2 image/s, 24fps)]]></Description>
  40.                 <Category><![CDATA[IMAGES 1280]]></Category>
  41.                 <Arguments><![CDATA[-r 2/1
  42. -i "<FullSourceFileName>"
  43. -s 1280x720
  44. -r 24
  45. -vcodec libx264
  46. -pix_fmt yuv420p
  47. "<OutputPath><OutputFileName>.mp4"]]></Arguments>
  48.                 <Arguments2><![CDATA[]]></Arguments2>
  49.                 <Postprocess><![CDATA[]]></Postprocess>
  50.         </Preset>
  51.         <Preset>
  52.                 <UUID>d1bf7e3a-3ca2-4b73-b12a-300c4fe90393</UUID>
  53.                 <Executable>ffmpeg.exe</Executable>
  54.                 <Name>Image sequence to video 1280x720, 1i/5s, 24fps</Name>
  55.                 <Description><![CDATA[Convert sequence of images to video (1280x720, 1 image/5s, 24fps)]]></Description>
  56.                 <Category><![CDATA[IMAGES 1280]]></Category>
  57.                 <Arguments><![CDATA[-r 1/5
  58. -i "<FullSourceFileName>"
  59. -s 1280x720
  60. -r 24
  61. -vcodec libx264
  62. -pix_fmt yuv420p
  63. "<OutputPath><OutputFileName>.mp4"]]></Arguments>
  64.                 <Arguments2><![CDATA[]]></Arguments2>
  65.                 <Postprocess><![CDATA[]]></Postprocess>
  66.         </Preset>
  67.         <Preset>
  68.                 <UUID>5107fcff-6305-4317-9dd9-3863f99c599f</UUID>
  69.                 <Executable>ffmpeg.exe</Executable>
  70.                 <Name>Image sequence to video 1920x1080, 2ips, 24fps</Name>
  71.                 <Description><![CDATA[Convert sequence of images to video (1920x1080, 2 image/s, 24fps)]]></Description>
  72.                 <Category><![CDATA[IMAGES 1920]]></Category>
  73.                 <Arguments><![CDATA[-r 2/1
  74. -i "<FullSourceFileName>"
  75. -s 1920x1080
  76. -r 24
  77. -vcodec libx264
  78. -pix_fmt yuv420p
  79. "<OutputPath><OutputFileName>.mp4"]]></Arguments>
  80.                 <Arguments2><![CDATA[]]></Arguments2>
  81.                 <Postprocess><![CDATA[]]></Postprocess>
  82.         </Preset>
  83.         <Preset>
  84.                 <UUID>1cf678cb-07ce-42c1-bca3-bade905d49a8</UUID>
  85.                 <Executable>ffmpeg.exe</Executable>
  86.                 <Name>Image sequence to video 720x400, 2ips, 24fps</Name>
  87.                 <Description><![CDATA[Convert sequence of images to video (720x400, 2 image/s, 24fps)]]></Description>
  88.                 <Category><![CDATA[IMAGES 720]]></Category>
  89.                 <Arguments><![CDATA[-r 2/1
  90. -i "<FullSourceFileName>"
  91. -s 720x400
  92. -r 24
  93. -vcodec libx264
  94. -pix_fmt yuv420p
  95. "<OutputPath><OutputFileName>.mp4"]]></Arguments>
  96.                 <Arguments2><![CDATA[]]></Arguments2>
  97.                 <Postprocess><![CDATA[]]></Postprocess>
  98.         </Preset>
  99.         <Preset>
  100.                 <UUID>91fe525a-abdc-4858-8e51-41e61d848754</UUID>
  101.                 <Executable>ffmpeg.exe</Executable>
  102.                 <Name>Image sequence to video 720x400, 5ips, 30fps</Name>
  103.                 <Description><![CDATA[Convert sequence of images to video (720x400, 5 image/s, 30fps)]]></Description>
  104.                 <Category><![CDATA[IMAGES 720]]></Category>
  105.                 <Arguments><![CDATA[-r 5/1
  106. -i "<FullSourceFileName>"
  107. -s 720x400
  108. -r 30
  109. -vcodec libx264
  110. -pix_fmt yuv420p
  111. "<OutputPath><OutputFileName>.mp4"]]></Arguments>
  112.                 <Arguments2><![CDATA[]]></Arguments2>
  113.                 <Postprocess><![CDATA[]]></Postprocess>
  114.         </Preset>
  115. </AnotherGUI_Presets_ver.03>

Addendum2: Forgot to mention, if it can't find ffmpeg.exe then go Preferences and click the Reset executable paths button, you can then select the paths to various executables, (AnotherGUI can handle more than just ffmpeg), or click the Cancel button in the dialog if you don't have that executable.
« Last Edit: January 14, 2015, 10:41:40 PM by 4wd »

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,721
    • View Profile
    • The Blog of Deozaan
    • Read more about this member.
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #8 on: January 15, 2015, 10:20:11 PM »
If you let me know what fps/dimensions/codecs you're interested in, I'll try knocking up some presets so you can look at them - specify image persistence in seconds and video output frame rate.

I'm interested in 60fps input/output. One image for each frame, each frame taking up 1/60 of a second to display. 60fps for nice, smooth visuals. Also because then I can just use 1 screenshot per second and it converts nicely to each second of video representing 1 minute of realtime for my timelapses.

I tend to stick to 2560x1440 (my monitor's native resolution) or 1920x1080 (1080p). But I also have a 1920x1200 monitor I may want to take snapshots of and convert to video.

I pretty much only use YouTube to upload, and they have some recommended codecs/bitrates here.


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,475
    • View Profile
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #9 on: January 16, 2015, 04:07:02 AM »
Try these, you might run into some problems with such a high input frame rate so check the output.

Use the preset under IMAGES Native Res as this won't do any scaling of the images and might avoid any frame drops, it'll pay to source the images from an SSD, RAM drive, or something similarly as fast.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,721
    • View Profile
    • The Blog of Deozaan
    • Read more about this member.
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #10 on: January 16, 2015, 11:15:35 AM »
Try these, you might run into some problems with such a high input frame rate so check the output.

Use the preset under IMAGES Native Res as this won't do any scaling of the images and might avoid any frame drops, it'll pay to source the images from an SSD, RAM drive, or something similarly as fast.

Thanks!

I could be wrong, but I don't think it has to actually read them in real-time in order for it to output the video at 60fps the way I want it. As it is processing the images, it tells me how many frames it is processing per second. Sometimes it's higher than the output rate, sometimes it's a lot lower than the output rate. But the output video still looks good when it's all done.

Also, I'm still not convinced there's a difference between input rate and output fps. It looks like you transposed the numbers (60/1 = 60) but the output still looks as it should with a different image each frame, running at 60 frames per second.

Either way, I just tried it out and it seems to have made a video that is virtually identical to one I made earlier. The file sizes are slightly different, but other than that they appear visually identical to my untrained eyes. So thanks again!


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,475
    • View Profile
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #11 on: January 16, 2015, 04:14:03 PM »
Also, I'm still not convinced there's a difference between input rate and output fps. It looks like you transposed the numbers (60/1 = 60) but the output still looks as it should with a different image each frame, running at 60 frames per second.

Since you've only just mentioned the input/output you wanted in your previous post, then in your case there is no difference - the number of images to copy as frames equals the number of frames in the frame rate.

Consider though if you'd said you wanted 30 images per second and the output video to be 24 frames per second - 6 frames, (each one being an image), would be dropped.

Or that you'd said that you wanted 16 images per second at 30 frames per second - 15 frames would be duplicated, 2 would be dropped or maybe 13 would be duplicated and 4 wouldn't be (thus only appearing for half the time as the others).

In case you were wondering, I hadn't looked at the videos you imbedded because no Youtube videos show up in DC when viewing the site via HTTPS - and I try to avoid Youtube anyway - so I didn't know what format your videos were ... sorry  :)

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,721
    • View Profile
    • The Blog of Deozaan
    • Read more about this member.
    • Donate to Member
Re: IDEA: Convert sequence of images to video (with ffmpeg?)
« Reply #12 on: January 16, 2015, 05:18:03 PM »
I may not understand how it works, but it does seem to work, and that's the important part. :mrgreen:

Thanks!