Batch avi to image sequence using ffmpeg [SOLVED]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Whale Cooper
Posts: 2
Joined: 30 Aug 2012 12:37

Batch avi to image sequence using ffmpeg [SOLVED]

#1 Post by Whale Cooper » 30 Aug 2012 12:54

Hey guys! Long story short.
I'm using ffmpeg to convert .avi file into a .png image sequence. This one works just fine:

Code: Select all

@ ECHO OFF

FOR %%A IN (*.avi) DO CALL :avi2png "%%A"

:avi2png
ffmpeg.exe -y -i %* -sameq -f image2 -c:v png "%%03d.png"

ECHO.
GOTO :EOF

But I want the script to extract the name without the extension from .avi file that is currently being processed. This is what the image sequence should look like: currentavi001.png, currentavi002.png etc. The script I came up with isn't working:

Code: Select all

@ ECHO OFF

FOR %%A IN (*.avi) DO CALL :avi2png "%%A"

:avi2png
ffmpeg.exe -y -i %* -sameq -f image2 -c:v png "%%~nA%%03d.png"

ECHO.
GOTO :EOF

I've tried both %~nA and %%~nA, but to no avail. The script returns this:

Code: Select all

Couldn't open file : 
av_interleaved_write_frame(): Input/output error.

I'm a complete layman and would welcome every bit of help.
Last edited by Whale Cooper on 31 Aug 2012 07:17, edited 1 time in total.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Batch avi to image sequence using ffmpeg

#2 Post by Squashman » 30 Aug 2012 19:49

There is no need to use a Call in this situation. Remove the call and put your ffmpeg code up with the for loop.

If you are going to use the call then your file name is in the %1 variable.
So if you want just the file name without the extension then you would use %~n1 to get the file name without the extension.

Whale Cooper
Posts: 2
Joined: 30 Aug 2012 12:37

Re: Batch avi to image sequence using ffmpeg

#3 Post by Whale Cooper » 31 Aug 2012 06:53

Thanks a million, Squashman! Works like a charm.

Post Reply