1

How to use ffmpeg to convert the entire content of a folder with all of it's subfolders, but only targeting videos with the formats .mpg, .avi and .vob.

Moreover, I want the output folders to be the same as the input folders and the output name to be the same as the input name, but the output file extension of course to be .mp4.

I tried writing a batch script to do so, but to no avail.

@echo off
    
set "source_folder=C:\path\to\source\folder"

for /r "%source_folder%" %%F in (*.avi *.mpg *.vob) do (
    ffmpeg -i "%%F" -c:v libx264 -c:a aac -strict experimental -b:a 192k "%%~dpnF.mp4"
   )
4
  • What error / result are you getting? Commented Jun 8, 2023 at 10:56
  • no such file or directory Commented Jun 8, 2023 at 11:05
  • Why batch and not e.g. PowerShell?
    – Destroy666
    Commented Jun 8, 2023 at 11:06
  • there are some parentesis missing.... Commented Jun 8, 2023 at 14:32

1 Answer 1

1
@echo off 

cd /d "D:\The\Full\Path\To\Folder\"

set "_FFbin=C:\Program Files\FFmpeg\bin\ffmpeg.exe"
set "_FFswt=-hide_banner -v error -stats -c:v libx264"
set "_FFswt=%_FFswt% -c:a aac -strict experimental -b:a 192k"

for /f ^delims^= %%i in =;(' 2^>nul %__AppDir__%where.exe /r . *.avi *.vob *.mpg
    ');= do echo/ & echo\ Input: "%%~dpnxi" && echo\Output: "%%~dpni.mp4" && =;(
         "%_FFbin%" -y -i "%%~dpnxi" %_FFswt% "%%~dpni.mp4" && echo========= );=


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .