-1

How would I create a batch file or simply a command to run ffmpeg instructions on an entire directory? I wish to transmux a folder of .ts files to .mp4

For individual files I use the command:

ffmpeg -i file.ts -acodec copy -vcodec copy file.mp4
Gerhard
  • 18,114
  • 5
  • 20
  • 38

1 Answers1

1

You would need a for loop to do that. So in a batch-file:

@echo off
for %%i in (*.ts) do ffmpeg -i "%%i" -acodec copy -vcodec copy "%%~ni.mp4"

I suggest you read up on some of the help available for this command via cmd.exe specifically focus on the "substitution of FOR variable references" section to understand how variables are expanded. simply run:

  • for /?

You can find alot more helpful commands by running help and then running the shown commands with the /? switch available to each of them.

SideNote if you plan on running this from cmd and not a batch-file then we need to use single %

for %i in (*.ts) do ffmpeg -i "%i" -acodec copy -vcodec copy "%~ni.mp4"
geisterfurz007
  • 3,390
  • 5
  • 29
  • 46
Gerhard
  • 18,114
  • 5
  • 20
  • 38