Error creating folder based on file name in ffmpeg - 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.

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.

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.

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?

FFMPEG Batch Convert for Windows [duplicate]

This question already has answers here:
How do you convert an entire directory with ffmpeg?
(34 answers)
Closed 3 years ago.
I've been trying to convert entire folders of files using ffmpeg for a long time now. I've searched the web, found various answers, but none that helped me. Currently I'm using multiple instances of ffmpeg to convert more than one file at a time. But it's very time consuming and annoying to type in everything all the time, even with copy/paste.
To simplify my current code it would look something like this. I specify the input file and the output format (+ various settings):
ffmpeg -i "EXAMPLE.avi" newEXAMPLE.mp4
But what I would like is a single instance of ffmpeg to convert all files in a specific folder to a new format and for the files to keep their original name.
example1.avi > example1.mp4
example2.avi > example2.mp4
example3.avi > example3.mp4
and so on...
PS. I'm a bit new to these kind of things, so I'd much appreciate an explanation with your answer, so I can understand and learn. Thank you!
for /f "tokens=1 delims=." %a in ('dir /B *.avi') do ffmpeg -i "%a.avi" "%a.mp4"
This is for cmd window usage, if you want to use it in the batch script, than double all percent signs. You have run it in directory where your videos reside.
In order to make ffmpeg batch encoding easier for Windows users, I developed this free open-source application using .NET/C#. I would like to include it here as an addtional choice to make things easier for some Windows users who may not be so familiar with command-line operation.
https://sourceforge.net/projects/ffmpeg-batch
If you have multiple periods in your file names, you can use this method instead:
for /r C:\path\ %a in (*.avi) do ffmpeg -i "%a" "%~pa%~na.mp4"
Just edit "C:\path\" as necessary.

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.

Resources