Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFMPEG Batch Convert for Windows [duplicate]

Tags:

ffmpeg

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!

like image 360
Ash_dog Avatar asked Apr 29 '17 12:04

Ash_dog


3 Answers

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.

like image 120
user2956477 Avatar answered Jan 03 '23 16:01

user2956477


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

like image 42
Eibel Avatar answered Jan 03 '23 14:01

Eibel


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.

like image 44
Dominic Mason Avatar answered Jan 03 '23 16:01

Dominic Mason