I have over 700 files that I need to take a screenshot at a specific time. I have been doing this one by one, but it is very time consuming. How could I do this with an ffmpeg batch file?
I also need the output of the file to be named the same as the video input.
I've been using this command:
ffmpeg -ss 00:03:45 -i "input.Mp4" -vframes 1 -q:v 2 "output.jpg"
Use this as batch file
for %%i in (*.mp4) do ffmpeg -ss 00:03:45 -i "%%i" -vframes 1 -q:v 2 "%%~ni.jpg"
Related
I want to be able to run a script in a folder that contains different angles of a video for example: 0007A,0007B,0008A,0008B. I was able to create it by writing the group of videos but I have like 300 different pairs of those video files and I would like to automatize it, here the one I created using 4 angles:
set n=%1
set i=
set /p savingFolder=Please specify URL of the folder to save the files to:
:loop
set i=%i%!
SET /p groupOfVideos=Please write the group of videos you want me to process:
ffmpeg -i %groupOfVideos%E.avi -i %groupOfVideos%F.avi -i %groupOfVideos%G.avi -i %groupOfVideos%H.avi -filter_complex "[0:v][1:v]hstack=inputs=2[top]; [2:v][3:v]hstack=inputs=2[bottom]; [top][bottom]vstack=inputs=2[v]" -map "[v]" -c:v libx264 -pix_fmt yuv420p %groupOfVideos%Z.avi
if i == n GOTO end
move /Y %groupOfVideos%Z.avi %savingFolder%
GOTO loop
As You can see, the loop is created to go back to the question and asks for the next group of video to execute the command with ffmpeg. This time I just would like to include this maybe in a for so each time the for runs gets the pair and then execute the ffmpeg command without asking anything. I have two days thinking on this but maybe I'm looking in a different way.
ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
for %%G in (*A.mp4) do (
set /p MP4A='file %%G'
if exist %MP4A:~0,4%B.mp4 (
set /p MP4B=%MP4A:~0,4%B.mp4
)
ffmpeg -i %MP4A% -i %MP4B% -filter_complex hstack=inputs=2 -c:v libx264 -pix_fmt yuv420p %MP4A:~0,4%L.mp4
pause
)
I'm trying to write a batch file that can be launched from Handbrake GUI with the "send file to" feature, that will split an MKV into chapters with MKVmerge, then convert all those new files into mp4s with ffmpeg. Handbrake passes only one argument into the batch file, the full file path of the output (surrounded by quotes). I'm very new to batch scripting and am having difficulty getting it all to work together -- all the individual parts work just fine when absolute paths are given. Here's the content of the .bat file:
START /WAIT "C:\Program Files\MKVToolNix\mkvmerge.exe -o output.mkv --split chapters:all %1"
for %%i in (*.mkv) do C:\ffmpeg\bin\ffmpeg.exe -i "%%i" -loop 1 -i "%%~dpi"\folder.jpg -map 1:v -map 0:a -c:a ac3 -b:a 640K -pix_fmt yuv420p -c:v libx264 -shortest -fflags +shortest -max_interleave_delta 100M "%%~ni.mp4"
Any glaring mistakes I'm making? I've been at this for hours reading SO threads and documentation, and can't figure it out for the life of me. Any help is appreciated, thanks in advance.
c:
cd c:\ffmpeg\bin
ffmpeg -f dshow -video_size 320x240 -framerate 30 -pixel_format yuv420p -i video="Logitech HD Pro Webcam C910" -t 00:00:10 C:\ffmpeg\bin\video.mp4
ffmpeg -f dshow -i video="Logitech HD Pro Webcam C910" C:\ffmpeg\bin\picture1.jpeg
ffmpeg -f dshow -i video="Logitech HD Pro Webcam C910" C:\ffmpeg\bin\picture2.jpeg
move C:\ffmpeg\bin\picture1.jpeg C:\Users\Owner\Desktop\TestFolder
move C:\ffmpeg\bin\picture2.jpeg C:\Users\Owner\Desktop\TestFolder
move C:\ffmpeg\bin\video.mp4 C:\Users\Owner\Desktop\TestFolder
ren C:\Users\Owner\Desktop\TestFolder\picture1.jpeg Picture-%date:~4,2%-%date:~7,2%-%date:~10,4%_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.jpeg
ren C:\Users\Owner\Desktop\TestFolder\picture2.jpeg Picture-%date:~4,2%-%date:~7,2%-%date:~10,4%_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.jpeg
ren C:\Users\Owner\Desktop\TestFolder\video.mp4 Video-%date:~4,2%-%date:~7,2%-%date:~10,4%_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.mp4
taskkill /im ffmpeg.exe /t /f
I've created a batch file that will take a ten second video and two screenshots from my webcam. My batch file works correctly until I try to rename the files. I don't understand why it is not working because I've used this code on another computer before and just copied, pasted it, and adjusted the file names around so it would work for my purposes. Any help would be greatly appreciated.
I found this script in another thread and edited it to make this:
#echo off
for %%F in (*.jpg) do (
if exist "%%~nF.mp3" (
ffmpeg -loop 1 -i "%%~nF.jpg" -i "%%~nF.mp3" -acodec libvo_aacenc -vcodec mpeg4 -shortest "%%~nF.mp4"
)
)
It combines all mp3 files with all jpeg files that share the same filename into a mp4 video with the static image running.
But the problem is - if I want to convert more than one mp3 file using the same image (let's say three mp3s), I have to duplicate the same jpeg image three times!
For example, if I have three Michael Jackson mp3 files:
MJ1.mp3
MJ2.mp3
MJ3.mp3
I would need to create:
MJ1.jpg
MJ2.jpg
MJ3.jpg
But really I only need one image for all three mp3s.
What edits do I need to make to the script combine all mp3s with one jpeg file? Let's say I wanted every mp3 file in the folder to convert with default.jpg. How would I do this?
Invert the loop. Instead of iterating over the images, iterate over the sound files.
#echo off
for %%F in (*.mp3) do (
ffmpeg -loop 1 -i "default.jpg" -i "%%~nxF" -acodec libvo_aacenc -vcodec mpeg4 -shortest "%%~nF.mp4"
)
I'm using the following ffmpeg script to convert all .mp4 files in the folder to .webm.
for %%A IN (*.mp4) DO ffmpeg -i "%%A" -c:v libvpx -crf 4 -b:v 3M -c:a libvorbis "%%A.webm"
I am trying to make it go from "xxx.mp4" to "xxx.webm"
However when I run the script the file name goes from "xxx.mp4" to "xxx.mp4.webm"
Any suggestions are highly appreciated.
Use %%~nA.webm to select the name-part of the filename.
see for /? from the prompt or documentation.
To recursively convert in webm all the mp4 video files in nested folders, you can try this command:
find '~/Video/' -iname '*.mp4' -exec bash -c 'D=$(dirname "{}"); B=$(basename "{}"); mkdir "$D/webm/"; ffmpeg -i "{}" -c:v libvpx -crf 4 -b:v 3M -c:a libvorbis "$D/webm/${B%.*}.webm"' \;
It will create a folder named "webm" inside the one with mp4 video files and, inside the "webm" folder, it will save relative webm files, without keeping the old file extension in the name.