Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFMPEG - Batch convert subfolders

I am trying to set up a Windows batch file to convert a number of MP4 files using FFMPEG. There are a number of files in multiple subfolders, therefore I need the script to execute on each file in each subfolder.

I'm afraid I don't have much experience of using batch files but from my research I've got the following command text:

FOR %%i in (*.mp4) /R DO (ffmpeg32 -i "%%~ni.mp4" -map 0:0 -map 0:1 -map 0:1    -c:v copy   -c:a:0 aac -b:a 128k -ac 2 -strict -2 -cutoff 15000  -c:a:1 copy "%~ni&(2).mp4")

The script basically needs to add an AAC audio stream to an existing MP4 file, therefore I need to change the output name by adding a (2) at the end of the filename.

I've tested the ffmpeg command separately so happy that it works - I just need to get the correct batch commands.

Thanks in advance for any pointers!

Cheers

like image 485
user2306403 Avatar asked Apr 22 '13 07:04

user2306403


1 Answers

Try this:

@echo off & setlocal
FOR /r %%i in (*.mp4) DO ffmpeg32 -i "%%~fi" -map 0:0 -map 0:1 -map 0:1 -c:v copy -c:a:0 aac -b:a 128k -ac 2 -strict -2 -cutoff 15000 -c:a:1 copy "%%~dpni(2)%%~xi"
like image 163
Endoro Avatar answered Sep 29 '22 23:09

Endoro