So, I tried a few lines of code in a Windows batch file to extract frames from MP4-files.
ffmpeg -i "filename.mp4" "frames/out-%%06d.jpg" works on just one file.
ffmpeg -i "*.mp4" "frames/out-%%06d.jpg"does not work at all.
How do I get it to play nice with multiple inputfiles?
Here is a possible solution:
for %%A in ("*.mp4") do ffmpeg -i "%%A" "frames\%%~nA_out-%%06d.jpg"
Note: Your example was not good as it will continuously replace file out-%%06d.jpg!
%%~nA is the filename of the mp4 file is being processed.
Type for /? in a fresh cmd for more information.
Related
I need some help.I try work automation to eliminate unnecessary time, I was looking for a way to convert video files to gif files.
So I learned how to make it using ".bat" through Googling, and want to make it a ".bat file" that automatically converts all mp4 files at one click because only one file is converted at a time.
it worked perfect for me. but I got a lot of vidoe files what i have to convert. I installed ffmpeg in my PC(#window)
this is what i find
#echo off
chcp 65001
cls
setlocal
echo 프레임 수치를 설정하세요
set /p fps=
ffmpeg.exe -i "%~1" -vf "fps=%fps%,scale=860:-1:flags=lanczos,palettegen" "%~n1.png"
ffmpeg.exe -i "%~1" -i "%~n1.png" -lavfi "fps=%fps%,scale=860:-1:flags=lanczos [x]; [x][1:v] paletteuse" "%~n1.gif"
del "%~n1.png"
goto :a
Thank for reading it.
I am trying to convert a large set of image sequences (each contained within its own subfolder) to video files. I can currently convert one sequence at a time by using ffmpeg and this code:
ffmpeg -r 30 -i "Image%%05d.jpg" -vf scale=1376:768 -qscale:v 2 "Display 1.m2v"
I also occasionally batch convert avi files which are contained within a single folder using:
for %%a in ("*.avi") do ffmpeg -i "%%a" -qscale:v 2 "%%~na.m2v"
I assumed I'd be able to use this batch approach with separate image sequences.
What I’m having trouble with is figuring out the syntax for a similar batch code that will convert whatever image sequence is present in a folder (or subfolder) using the anyfile%%05d naming convention. The %%a syntax in the second line of code doesn’t seem to be compatible with the way ffmpeg recognizes image sequences anyfile%%05d in the first. Any thoughts?
According to your last comment all you need is then to:
iterate the subfolders of a base dir and evtl.
cd/pushd in there run your one working line and
step out and repeat until all subfolders are processd.
This is quite basic batch stuff.
#echo off
Pushd "X:\folder\to\start"
For /D %%A in (*) do (
Pushd "%%~fA"
ffmpeg -r 30 -i "Image%%05d.jpg" -vf scale=1376:768 -qscale:v 2 "Display 1.m2v"
PopD
)
PopD
I'm trying to get all .png files in a folder to be converted into a video format in the same directory as the images. Now I can't understand how ffmpeg works, I just want something like this;
for /l %%k in (1,1,%images%) do (
ffmpeg.exe (I need help with the parameters here)
)
This is my very first help request ever and I'm not sure if I supplied enough information for this to be an easy answer. But at least TRYING to help me would be much appreciated. Thank you for reading!
#echo off
set /p framerate=Enter framerate:
for /r %%a in (*.png) do (
echo file '%%a' >> images.txt
)
ffmpeg.exe -r %framerate% -f concat -i images.txt -c:v libx264 -pix_fmt yuv420p video.mp4
del /q images.txt
Put this batch file AND ffmpeg.exe in the directory of all images
Run the batch file and all images in that the current folder will be converted into an mp4
The batch file will automatically close after it has completed
I would like to concatenate 3 mp4 videos into one avi video for every folder of a directory, with FFMPEG on Windows 7.
I have started this way:
ffmpeg -f concat -i mylist.txt -c copy E:\EA2014\EX14R\EX14R.avi
with mylist.txt being:
file 'E:\EA2014\EX14R\DCIM\100GOPRO\GOPR0001.MP4'
file 'E:\EA2014\EX14R\DCIM\100GOPRO\GP010001.MP4'
file 'E:\EA2014\EX14R\DCIM\100GOPRO\GP020001.MP4'
This works fine. Now, I would like to automate it because I have lots of those folders full of videos to merge.
I tried with this to start with:
printf "file '$s'\n" .E\EA2014\EX14R\DCIM\100GOPRO\*.MP4 >> mylist.txt
But it tells me that
"printf is not recognized as an internal or external command, operable program or batch file"
Is it because I work in Windows? Anyone could help me achieve it in another way?
Needless to say that I am a newbie!
Thanks!
This should process each folder under the E:\EA2014\EX14R tree and create the .avi file in each individual folder, calling it myfile.avi
#echo off
for /d /r "E:\EA2014\EX14R" %%a in (*) do (
if exist "%%a\*.mp4" (
del mylist.txt 2>nul
for %%b in ("%%a\*.mp4") do >>mylist.txt echo file '%%b'
ffmpeg -f concat -i mylist.txt -c copy "%%a\myfile.avi"
del mylist.txt 2>nul
)
)
I am trying to figure out how to create a script that will take all video files in a folder videos\*.* and then use ffmpeg on each one and output the files to converted\*.mp4 where the filenames are the same.
However, I can't figure out how to get the for loop working, so that I can extract the name and extension type of file I am processing.
for %%f IN (videos\*.*) DO (convert.bat %%f)
convert.bat
ffmpeg.exe -i %1 -f mp4 converted\%~n.mp4
I have tried both with and without double quotes. However, it won't recognise the file.
One liner batch file command:
for %%F in (videos\*.*) do ffmpeg.exe -i "%%~fF" "%%~dpF\converted\%%~nF.mp4"
Two liner as you had it: (Added call command, quotations, and ~)
for %%F IN (videos\*.*) DO (call convert.bat "%%~fF")
convert.bat (Corrected parameter usage with ~, options, and quotations)
ffmpeg.exe -i "%~f1" "%~dp1\converted\%~n1.mp4"
See for /?, call /?, ffmpeg for help.