Consider the following bash script (on Ubuntu 18.04, melt 6.6.0), which uses melt to make a slideshow and play it locally in a window (SDL consumer), mostly copied from https://mltframework.org/blog/making_nice_slideshows/ ( edit: I'm aware that's its possible to specify files individually as in https://superuser.com/questions/833232/create-video-with-5-images-with-fadein-out-effect-in-ffmpeg/834035#834035 - but that approach seems to scale images during transition, and takes quite a while to "render" before playing in SDL window, while this one has nearly instant playback):
echo "
description=DV PAL
frame_rate_num=25
frame_rate_den=1
width=720
height=576
progressive=0
sample_aspect_num=59
sample_aspect_den=54
display_aspect_num=4
display_aspect_den=3
colorspace=601
" > my-melt.profile
mkdir tmppics
convert -background lightblue -fill blue -size 3840x2160 -pointsize 200 -gravity center label:"Test A" tmppics/pic_01.jpg
convert -background lightblue -fill blue -size 3840x2160 -pointsize 200 -gravity center label:"Test B" tmppics/pic_02.jpg
melt -verbose -profile ./my-melt.profile \
./tmppics/.all.jpg ttl=6 \
-attach crop center=1 \
-filter luma cycle=6 duration=4 \
-consumer sdl
-profile, a default one is assumed; is that correct?
... and the video looks like this:

... which means the aspect ratio is wrong; additionally I can see jagged edges, meaning the scaled image in the video is not antialiased.
How do I make the image fit in video size with correct aspect ratio, with antialiasing/smoothing? (I guess it has to do with -attach crop center=1, but I couldn't find documentation on that).
When viewing stuff in SDL and stepping through frames, are frames numbered 0-based, - or are they 1-based, and at frame 0 simply the same frame as 1 is shown?
If I use ttl=6 and -filter luma cycle=6 duration=4, I get this:

... that is, visible transition starts at frame 7 (frame 6 is full image A), lasts for frames 7 and 8, and ends at frame 9 (which is full image B); then again at frames 13 and 14 (frame 15 is full image A)
However, if I use ttl=6 and -filter luma cycle=6 duration=2, then I get this:

... that is, there is no transition, image instantly changes at frame 7, then again at frame 13, etc.
So, I'd call the first case a transition duration of 2 frames, and the second case a duration of 0 frames - yet the options are duration=4 and duration=2, respectively. Can anyone explain why? Where are those 2 frames of difference gone?
Can I - and if so, how - do the same kind of slideshow, except with fade to black? I'd like to define a "time to live" (ttl) of 6 frames per image, and a transition of 4 frames, such that:
... etc.
melt to use globbing to select images for slideshow, instead of using .all.jpg? As far as I can see on MLT (Media Lovin' Toolkit) Photo Slide Video no - but maybe there is another approach... Ok, so, I spent some time looking into the commands for melt and turns out there is actually a pretty effective way of altering a bunch of images (if the number of arguments is too long or there are too many characters for your terminal to handle).
What you want to do is to use -serialise <name of file>.melt which will store your commands (you can also create this file manually). Then to execute that file, use melt <name of file>.melt along with any other options you have for your video file.
melt <images and what to do to them> -serialise <name of file>.melt
melt image1.png out=50 image2.png out=75 -mix 25 -mixer luma image3.png out=75 -mix 25 -mixer luma image3.png out=75 -mix 25 -mixer luma image4.png out=75 -mix 25 -mixer luma <...> -serialise test.melt
image1.png
out=50
image2.png
out=75
-mix
25
-mixer
luma
image3.png
out=75
-mix
25
-mixer
luma
image3.png
out=75
-mix
25
-mixer
luma
image4.png
out=75
-mix
25
-mixer
luma
<...>
melt test.melt -profile atsc_1080p_60 -consumer avformat:output.mp4 vcodec=libx264 an=1
There should be an extra return character at the end of the melt file. If there isn't, Exceeded maximum line length (2048) while reading a melt file. will be outputted
Notice that -serialise <name of file>.melt will not be in the .melt file
Melt will actually take some time to load the melt file before the encoding process begins
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With