-1

I am using the following command within a batch script to, hopefully, eventually programmatically create simple video slideshows with transitions:

melt 131.jpg 132.jpg 133.jpg ttl=75 -attach crop center=1 -filter luma cycle=75 duration=25 -transition mix -consumer avformat:out.mp4 frame_rate_num=30 frame_rate_den=1

Most of this command is an adaptation for Windows of this command on the MLT website blog (with the exception of the part that scales and transforms the image). For some reason when I run this, however, the output video file is 25 minutes long!

I have two main questions:

a. How do I properly control the duration of each image in the video? I have experimented quite a bit with changing the parameters and I have a semi-decent understanding of what they all mean (I am a newbie to MLT but I figured that there's no way to do something like this easily in FFMPEG alone). The only way I have found to decrease the duration with any amount of control is to increase the output framerate to absurd numbers (which, of course, is not ideal as it's a massive waste of time and energy and still doesn't really solve the issue).

b. How do I use a wildcard to input all the .jpg files in a folder on Windows? I tried adding *.jpg but that didn't work and I don't know how else to do it within a batch script (I tried using the following code to get the file names as a variable, but I wasn't able to get string concatenation working correctly because it only outputs the final file name)

set files=
for /r %%i in (*.jpg) do (
    echo %%i
    set files=%files% "%%i"
)
echo %files%

Thank you for any suggestions!

Tjk
  • 11
  • 2

2 Answers2

0

Change

set files=%files% "%%i"

to

CALL set "files=%%files%% "%%i""

This uses a subsidiary process to concatenate your filenames.

I have no idea about the solution to your other question.

Magoo
  • 77,302
  • 8
  • 62
  • 84
0

When you specify a .jpg file, melt automatically chooses a producer internally. Depending on your environment and version, that producer will either be the qimage or pixbuf producer.

Both producers offer a "ttl" parameter to specify the duration of the image (in frames) for image sequences https://mltframework.org/plugins/ProducerQimage/#ttl

https://mltframework.org/plugins/ProducerPixbuf/#ttl

In the example you linked, an image sequence is created by using the special syntax: photos/.all.jpg ttl=75

In your example, you specify a specific file name. So an image sequence is not created. Instead, a new producer is created for each file. The default length for a producer is 15000 frames.

https://github.com/mltframework/mlt/blob/master/src/framework/mlt_producer.c#L102

The length can be specified in the command line.

melt 131.jpg length=100 132.jpg length=100 133.jpg length=100
Brian
  • 1,200
  • 6
  • 8
  • When I use the "photos/.all.jpg ttl=75" syntax, I get an error that says "Failed to load 'photos/.all.jpg'". I am using windows and I believe my version of melt is using qimage by default since the pixbuf producer is not listed when listing all producers. I have gotten a script to work that inserts each file name with a length tag (eg. img.jpg length=100 img2.jpg length=100 etc), however I havent gotten transitions working like this, and the syntax is very messy. Could you offer me any advice? – Tjk Nov 11 '20 at 04:07
  • Are your jpg files in a folder named "photos"? If not, you need to change the path. ".all.jpg" is a special wild card to tell the producer to find all files in the path specified. If you want a transition between each photo, you can not do that with ".all" because it will only create one producer. If you list each file as img1.jpg img2.jpg, then you need to add a "-transition" between each image. This will become a long command if you need to specify options for each transition. – Brian Nov 12 '20 at 02:04
  • Many people have success by using a tool that creates .mlt project files like Kdenlive and Shotcut. Use the tool to create the effects you want. Then, study the resulting xml file to learn the syntax. Then, write a script to automate building your own .xml file. Use melt to render the xml file. – Brian Nov 12 '20 at 02:05
  • Ah, I had tried using ".all.jpg" or "/.all.jpg" before, but it would always give me the same error. Turns out that you have to specify a directory, else the wildcard command wont work (eg. "directory/.all.jpg"). I also did find success with getting transitions between each photo using the single producer with wildcard method, surprisingly. Now my only problem is that the output video is always 10 minutes long, and loops through all the photos multiple times or cuts off excess photos to reach this length. I will likely move to using xml later, but is there a way to fix the length w/o xml?Thanks – Tjk Nov 12 '20 at 06:07
  • I suggest to add the autolength parameter or specify the length manually. https://mltframework.org/plugins/ProducerQimage/#autolength – Brian Nov 13 '20 at 03:23