I'm trying to figure out what PowerShell command [or script if necessary] might allow ffmpeg to recursively traverse a directory, pull stills via the -vf flag, and put all the stills into a folder without any filename conflicts that would cause overwriting.
So I know that this works fine for an individual file:
ffmpeg -i input.mov -vf fps=10/60 still%04d.jpgThe files generated start from still0001.jpg and count up to still0002.jpg, still0003.jpg, etc.
I have a directory that looks like this, with video files at different levels:
topFolder1midFolder1video1.movvideo2.mov
midFolder2video3.movvideo4.mov
I'm trying to use a PowerShell command that can pull stills from all the videos video1.mov, video2.mov, video3.mov, and video4.mov and drop them into one folder.
I found a PowerShell command that purports to have ffmpeg traverse a directory recursively, but when I try to adapt it, it's not working.
I run:
PS T:\Exports\1 - Dailies\stills test> for /F "tokens=*" "%G" IN ('dir "T:\Exports\1 - Dailies" *.mov') do ffmpeg -i "%G" -vf fps=10/60 still%05d.jpgBut I get this error:
At line:1 char:4
+ for /F "tokens=*" "%G" IN ('dir "T:\Exports\1 - Dailies" *.mov') do f...
+ ~
Missing opening '(' after keyword 'for'. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeywordWhere am I going wrong?
51 Answer
Here's an example of a powershell command for converting all files in a directory to mp4 and resizing to 1280x720:
dir *.* | foreach-object { $newname = $_.Name.Remove($_.Name.Length - $_.Extension.Length) + ".mp4"; .\ffmpeg.exe -i "$_" -s 1280x720 $newname } 1