问题
I have never dealt with .bat files before so this is new to me.
I'm trying to use FFMPEG to select all the .mp4 files from a folder I place the .bat file in. Then to get it to screenshot every 30 minutes, and output the files with the input file name + image number in JPEG
This is what i came up with so far:
for f in *.mp4; do ffmpeg -i "$f" -vf fps=1/1800 "${f%.mp4}.jpeg";done && cp --copy-contents *.jpeg ~*outputDirectory* && rm -R *.jpeg
Any help would greatly be appreciated.
回答1:
If I'm interpreting the ?bash? code correctly this should do:
@Echo off
Set "JPEGdir=%UserProfile%\Outputdirectory"
for %%f in (*.mp4) do ffmpeg -i "%%f" -vf fps=1/1800 "%JPEGdir%\%%~nf_%%d.jpeg"
- for variables need to be prefixed with
%%in a batch (single%on the cmd line) - instead of creating the JPEG in the source folder, copy and delete, it's easier to create them straight in the destination folder by using the destination path and only the filename without drive, path and extension %%~n for the new name, appending the ffmpeg function to append a number
%d(this percent sign has to be escaped with a second one)
Edit added folder creation:
@Echo off
Set "JPEGdir=%UserProfile%\Ouputdirectory"
for %%f in (*.mp4) do (
If not Exist "%JPEGdir%\%%~nf" MkDir "%JPEGdir%\%%~nf"
ffmpeg -i "%%f" -vf fps=1/1800 "%JPEGdir%\%%~nf\%%~nf_%%d.jpeg"
)
I derived the destination folder from your bash code, if you want the new folder in the current dir instead, just set "JPEGdir=."
回答2:
This is what i ended up with and it works perfectly now:
@Echo off
for %%i in (*.mp4) do (
ffmpeg -i "%%i" -vf fps=1/1800 "%%~ni_%%d.jpeg"
)
来源:https://stackoverflow.com/questions/43370521/ffmpeg-im-trying-to-use-ffmpeg-to-select-all-the-mp4-files-in-a-folder-and-s