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

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.

Related

Error creating folder based on file name in ffmpeg

I've been trying to convert multiple videos into image stacks using ffmpeg. I would like to convert multiple videos at once, and export all the images from one video into a new folder, named after the video.
I've found the following code from a previous question, but I can't get it to work on my computer (I'm using a mac).
#echo off for %%i in (*.mp4) do (if not exist "%%~ni\" MD "%%~ni" ffmpeg -i "%%i" -vf fps=1/1800 "%%~ni\%%~ni_%%d.jpeg")
I keep getting the error
parse error near %%i`
I think this is probably a syntax error, but I'm relatively new to using ffmpeg and working in the terminal.

Apple Automator, Shell Script and batch files - video subtitles

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

Crop Thumbnail and Replace Without Overwrite Prompt

This is probably a simple question. I couldn't find another question that worked with my particular code. The code below resizes images to 320x180 but when it goes to replace it ask me to type Y/N.
for %f in ("*.jpg") do (ffmpeg -i "%f" -filter:v scale="320:180:force_original_aspect_ratio=increase,crop=320:180" "%f")
I tried to add the -Y to automatically select yes, but it was not working out. Any idea how to auto-overwrite with this code?

Convert mp4 from color to black-and-white with linux terminal

I have an mp4 which I want to convert from color to black and white using the terminal.
How?
EDIT: My question is NOT a duplicate because I want to do this with an mp4 (video, not image).
If you install ffmpeg (cross-platform video converter), you can do it with a one line command by filtering the saturation to 0.
ffmpeg -i <inputfile> -vf hue=s=0 -acodec copy <outputfile>
Maybe overkill but GStreamer could probably achieve that. It's mainly for streaming media but you can use it to manipulate local files also.
https://gstreamer.freedesktop.org/
It can either be executed as a command taking your mp4 as argument along with a long series of other arguments directly from the terminal or the framework can be imported in a project. Takes some time to get the hang of it tho and it's probably an easier way.

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