MLT filter to control audio volume - mlt

I want to attach audio to video in such a way that the music plays in background in a very low volume. What would be the ideal way to do it? I cannot get the volume filter working in this case.
This is what I am trying
melt 1.mp4 -filter volume gain=20db -audio-track bensound-buddy.mp3 -attach volume gain=-10db

I was trying to decrease the volume from one track too and I found why it didn't work. Try to use that instead :
melt 1.mp4 -attach volume level=20db -track bensound-buddy.mp3 -attach volume level=-10db

Related

MLT melt slideshow on Windows: unable to control output video length and problems with using wildcards

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!
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
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.

Automating FFmpeg/ multi-core support

I need help with FFmpeg/batch. I have a couple of large batches of images (+14000 files each batch, +5 MB each image, .TIFF all of them) and I'm stringing them together into a .mp4 video using FFmpeg.
The date in the metadata is broken because of the way they're stored upon creation, so the time and date (T/D) are on the file_name. I need each frame to have its respective T/D (so its File_Name) burnt onto them for accurate measurements (scientific purpose).
With the help of google and reddit, I've managed to semi-automate it like so:
Master.bat:
forfiles /p "D:\InputPath" /m "*.TIFF" /S /C "cmd /c C:\SlavePath\slave.bat #file #fname"
Slave.bat:
ffmpeg -i "%~1" -vf "drawtext=text=%~2: fontcolor=white: fontsize=30: fontfile='C\:\\FontPath\\OpenSans-Regular.ttf'" "D:\OutputPath\mod_%~1"
Running Master.bat will output each individual image with the text burnt onto them and change the File_Name to mod_'File_name'.TIFF
Real example: 2018-06-05--16-00-01.0034.TIFF turns into mod_2018-06-05--16-00-01.0034.TIFF
The problem is that FFmpeg doesn't like it when my files have "--" in them ("date--time.miliseconds.TIFF") and doesn't like the miliseconds either, so I have to change the name of all files "manually" using Bulk Rename Utility (BRU). So, using BRU I rename all files to 00001.TIFF, 00002.TIFF, etc. and FFmpeg likes me again. It works great, but it means I can't be AFK.
After that, I have to go back to cmd and manually start the image to video conversion.
Also, FFmpeg doesn't seem to be using all cores.
I need help finding a way to:
Change master.bat's output to 00001.TIFF etc. automatically in order of processing (i.e. first to be processed is 1.TIFF, 2nd is 2.TIFF)
Add ffmpeg's img-to-vid function to the automating system
Get my CPU to use all the cores effectively if possible. 2014/15 posts found on google make it seem as though FFmpeg doesn't support multi-core or hyperthreading.
64bit Windows, i7 7700hq, gtx 1050 4Gb, C: SSD, D: HDD
Try this:
ffmpeg -i "2018-06-05--16-00-01.%4d.TIFF" -threads 4 out.mp4
https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence

Play sounds with a batch file

I want to play a sound or music file with Batch files, but I don't want that Windows show the window from the music player.
So I want to play a sound in the background...
I hope you can help me :D
Here are few scripts.
mediarunner.bat - it uses windows media player active x objects so you cannot used if there's no installed Windows Media Player (though it usually comes packed with the Windows).Accepts only one argument - the path to the file you want to play.
spplayer.bat - uses SP Voice objects but can play only .wav files.Again it accepts as only argument the path to the file you want to play.
soundplayer.bat - uses Internet Explorer objects and specific bgsound tag that can be used only in internet explorer.Can play .mp3,wav,.. files. It can accepts two arguments. The file you want to play and the sound volume (a number between -10000 to 0) :
call soundplayer.bat "C:\Windows\Media\Windows Navigation Start.wav" 0

Remove drive letters via batch or vbs scripting

I am searching for a little batch or vbs script that does the following:
Find the drives in a list of valid drive letters, e.g. ['c','d','e','f'], that have a specific drive name, e.g. 'BackupDrive'
Remove the drive letters of the found drives so that they are no more displayed in Windows Explorer
Any suggestion is very appreciated.
You can do this using the command line tool "diskpart". As stated in the official technet documentation if you know the volume name you can remove it with:
select volume <volume number>
remove letter=<Letter>
You can automate this either using a script file (as documented here) with the exact commands, or by calling the exe with objShell.Exec on the shell object in vbscript and manipulating the stdin and stdout accordingly. An example for that can be found here. In your case this would probably be the better approach because you could do a "list volume" there and then parse the result for description and label and act accordingly. Afaik this is sadly the only way to get to the volume number, because it is not present in wmi or somewhere easier queryable.
Please keep in mind that diskpart is a VERY powerful tool, that can wipe whole partitions, so use it with caution.
Also note:
You cannot remove the drive letters on system, boot, or paging
volumes. In addition, you cannot remove the drive letter for an OEM
partition, any GPT partition with an unrecognized GUID, or any of the
special, non-data, GPT partitions such as the EFI system partition.

What can i use to automate video snapshots

What command line util can i use to create a thumbnail preview of a video i made? I do not want a single thumb that windows make, i want a large jpg file that has 30 or less shots so i can preview the movie w/o running it.
I either need an app that can do a batch at once or a command line util so i can loop through a folder or w/e i need and feed it to the util. I was thinking of hacking up ffplay to do this, i dont know what i am getting myself into so is that recommended? (i used SDL many times, never its YUV settings nor with ffmpeg)
You can use ffmpeg to perform frame extraction, here's how I've done something similar
ffmpeg -i my_input_video.flv -y -an -sameq -f image2 -r 1 my_frame_%05d.jpg
-i my_input_video.flv specifies the input file
-y overwrite output files
-an disables audio (we're transcoding a video to a series of jpegs, we don't need audio)
-sameq - use same quality as source
-f image2 sets the output format to image2 (an image sequence)
The -r parameter is the frames per second, so the above command will produce one jpeg per second.
Once you have your collection of jpegs, you can use ImageMagick montage command to build a montage image.
You could use MTN. It can scan whole directories and create thumbnails for every video found.
Use mplayer:
mplayer -vo jpeg -frames 1 your_file
Will extract the first frame.
Media Player Classic can make a collection (it's called save as thumbnail; with matrix i.e. 4x4), but only from a single file.
Potplayer can automatically generate the thumbnails for a batch of videos in folders or even in subfolders. It just takes a few clicks.
Add all the videos you want to get thumbnails from to the playlist (You can do this by go to menu "Open-Open Folder...")
Select all the videos in playlist and right click on them.
Select "Create Thumbnail Image(s)..." in pop-up menu.
Custom the output folder, number of Thumbnails, image size and other setting.
Click "OK".

Resources