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
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.
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.
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 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.
#echo off
setlocal enabledelayedexpansion
set EXE_FILE=E:\ffmpeg.exe
set INPUT_PATH=C:\folder\
set OUTPUT_PATH=C:\Images\
set COUNT=0
for %%F in (*) do %EXE_FILE% -i %INPUT_PATH% %OUTPUT_PATH%/%%F.jpg
popd
I want to save 1 sec videos to jpg images with this code. This doesnt work. Any solutions?
INPUT_PATH should be a video file, rather than a directory. You need to iterate through the input videos instead of iterating through the output images. ffmpeg will output all the images by itself (without you iterating through them, ie with a single command). Look at this guide for help. Here is an example from that guide:
ffmpeg -i video.mpg -r 1 -f image2 ffmpeg_temp/%05d.png
So what you're really doing in your script is you are making the number of digits in the name of the output images more and more.
%05.png will make image file names look like "00001.png", and %03.png will look like "001.png", etc.
But what you want is to go through the input files, so iterate through for example "video1.mp4", "video2.mp4", etc.
IF EXIST %~d1%~p1%~n1.jpg GOTO exit
setlocal enabledelayedexpansion
set EXE_FILE=E:\ffmpeg.exe
set OUTPUT_PATH=E:\Glasgow\Test
set COUNT=0
for %%F in (*.avi) do %EXE_FILE% -i %~d1%~p1%~n1.avi -r 1 -vframes 1 -ss 00:00:01 -f image2 -y %~d1%~p1%~n1.jpeg
popd