Ran Shorowitz
Ran Shorowitz

Reputation: 315

FFMPEG command works in PowerShell but not in a batch file

Simply trying to extract frames from a video file using ffmpeg in a .bat file and it doesn't work:

ffmpeg -i video.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 tmp_frames/frame%08d.jpg

The error message:

Unable to find a suitable output format for '.\tmp_frames\frameC:\Test' .\tmp_frames\frameC:\Test: Invalid argument

This command works fine in PowerShell by itself, but running it as a batch file yields the above error.

Any ideas on how to fix this in the batch file?

Upvotes: 0

Views: 362

Answers (2)

Klompengard
Klompengard

Reputation: 304

In the .bat file, you must use the escape code for %, which is %%

ffmpeg -i video.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 tmp_frames/frame%%08d.jpg

Upvotes: 4

Magoo
Magoo

Reputation: 80213

...frame%08d.jpg : %0 will be replaced by the current batchfile name, hence '.\tmp_frames\frameC:\Test'

Upvotes: 2

Related Questions