Apple Automator, Shell Script and batch files - video subtitles - ffmpeg

I'm making a Workflow to burn SRT to MP4. It's is working but I want it to go to all files of a folder and didn't find a way even with "Dispense Items Incrementally".
I have the SRT and the MP4 in the same folder, so I need the workflow to filter the results to only try the script with the MP4 files and maybe this is the problem for "Dispense Items".
Because the subtitled file goes to the same directory, the filter also excludes files named with "_SUB".
The image is below if someone has an idea... I'm open to other methods of doing this. I just need to go to a folder with 44 MP4 files (and .SRT with the same name) and batch encode the videos with subtitles.
Thank you,
Luiz
enter image description here

Open Terminal, navigate to the directory containing the files, and run:
for f in *.mp4; do ffmpeg -i "$f" -vf "subtitles=${f%.*}.srt" -c:a copy "${f%.*}_srt.mp4"; done

Related

FFMPEG batchfile to compress images JPG JPEGs and keep EXIF (metadata)

I tried searching everywhere for a possible solution but I really can't find it. Hope someone can help me out here.
I have written a batch file to use FFMPEG to compress and sharpen JPGs in a folder.
FOR %%a in (*.jpg) DO (ffmpeg -i "%%a" -q:v 8 -vf unsharp=5:5:1.0:5:5:0.0 "2022 01 22 %%~na".jpg)
PAUSE
The new file comes out smaller in size, but is missing all the EXIF information that the original photo has.
I tried to add in the command "-metadata" but apparently it works for MP4 only. I have an existing solution with imageMagick but I'm hoping to solve this via FFMPEG. or is there a way to integrate exiftool into the batch file?
Thank you and I really appreciate any help here.

Download video+audio in a single file from YouTube

I tryed to download a video+audio from YouTube by using youtube-dl:
youtube-dl https://www.youtube.com/watch?v=7wfUUZvybPY
I got a video file (.webm) without audio. I'm looking for a way to download video+audio in a single file by using the command line (cmd) in Windows 10. Do you have any suggestion?
youtube-dl.exe --format mp4 https://www.youtube.com/watch?v=7wfUUZvybPY
However, youtube-dl relies on ffmpeg for many format conversions. Install ffmpeg for Windows and look at youtube-dl docs here
I found a solution; the following command merges the audio and video files in a file.mkv:
youtube-dl.exe --sub-lang en --write-sub https://www.youtube.com/watch?v=7wfUUZvybPY

Creating a batch file for ffmpeg to combine image sequence to mkv

I have been doing some work remastering some videos by converting them to image sequences, editing them, then converting them back to videos. To do the last step, I have been just using the command prompt with ffmpeg. My goal is to create a batch file that I can just put into the folder with my image sequence and run it rather than needing to do it through the command prompt manually.
Here is the command I've been running:
"C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe" -framerate 23.97 -i "%06d.png" -c:v copy "B:\output.mkv"
ffmpeg is located on my C drive, the image sequences are on my Z drive, but I generally move to that folder to run the command, and the images are always named with 6 digits (000000.png-######.png). The output file is created on the B drive.
I assumed that I could just add that command to a .bat file
"C:\Program Files (x86)\RipBot264v1.25.1\Tools\ffmpeg\bin\ffmpeg.exe" -framerate 23.97 -i "%06d.png" -c:v copy "B:\output.mkv"
pause
but I have not been able to get it to work. When I try to run it, I get an error that seems to be related to the name of the batch file itself:
Z:\S09E19"Z:\S09E19_Output.bat6d.png -c:v copy B:\output.mkv: Invalid argument
Any help on this would be greatly appreciated.

wav to m4a conversion via QuickTime with Automator

I have a bunch of huge .wav files which I want to convert to .m4a files via QuickTime export function.
As there are a lot of wav files I'd like to automate this process with Automator.
Could you please help me this task? The QuickTime player looks to be not recordable app for automator this is why I have to use Applescript which I do not know.
What I need is "Quick Action" which will be right click file/finder action: upon right click on a file I will choose "convert to m4a"
In my understanding the automator should get the file name and then export it as "Audio only" via Quicktime player.
In my primitive understanding it would be something like this -
tell application "QuickTime player"
activate
tell export rightClickedFile in file sameFolder using settings preset "Audio Only"
end tell
end tell
Any suggestions will be highly appreciated.
As you appear to be struggling with Automator, you could maybe consider using ffmpeg to convert your files.
To convert song.wav in your HOME directory into song.m4a at 320kb/s, you can run this in Terminal:
ffmpeg -i song.wav -c:a aac -b:a 320k song.m4a
If that looks good, you can do all the .wav file in the current directory with:
for f in *.wav; do ffmpeg -i "$f" -c:a aac -b:a 320k "${f%%.*}.m4a" ; done
As Apple doesn't provide a package manager, like many folk, I tend to use homebrew. Once you have homebrew installed, you can install, remove and maintain many hundreds of packages. You install ffmpeg with:
brew install ffmpeg

Tagging mkv files with cover images?

I found this screenshot which shows that you can add a cover image to an mkv file in a way that it is displayed as the icon of the file in the Windows explorer using Shark007+icaros.
But these tools are messing with the system in a really bad way. A lot of people are having problems with it and I too very much regret that I've installed it. I'm really glad I got my Windows to boot again...
Anyway, how could I programmatically add a cover image to an mkv file?
And would I need to change something in the registry to make Windows display them?
I'm not neccessarely looking for code, I'm more looking for something like the format the cover needs to have and the byte at which I have to inject/insert/attach the image file and maybe a registry entry that would cause the tagged images to be displayed etc.
You can use the FFmpeg multimedia framework to attach an image as MKV metadata. More Windows builds can be found at Zeranoe.
Example CLI usage:
ffmpeg -i input.mkv -c copy -attach image.jpg -metadata:s:t \
mimetype=image/jpeg output.mkv
-c copy copy all streams in the source file without re-encoding
-attach image.jpg attach a JPEG image
-metadata:s:t mimetype=image/jpeg set the attachement MIME type
On *nix the same can be accomplished with MKVToolNix.
Ubuntu demo:
Programmatic approach:
use the ffmpeg C libraries to attach or replace the cover art
write a custom Shell Extension to read the MKV format and display the image attachement as thumbnail.

Resources