Some helpful commands and batch files (mostly ffmpeg) #970
htmlcodepreview
started this conversation in
Show and tell
Replies: 2 comments 2 replies
-
thanks for your contribution. I had some 60 fps video's and was thinking about making them 30fps to double the speed. but i would delete every other frame. When you roop 12 fps on a 30 fps video. It will slow down the video, but instead of a 1800 frame 1 min video, wont you get a 2,7 min video with the same 1800 frames? so why would it be faster? |
Beta Was this translation helpful? Give feedback.
2 replies
-
Thank you very much. Very useful for me. Especially the merge and the resize tool. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using roop, especially this fork for a very long time now, and I want to give back to the community, even tho all I can contribute isjust a few cheap commands.
In order to use below commands you need to have ffmpeg installed. If you are using roop-unleashed you probably already have this. But you may still need to add ffmpeg to your PATH variable.
Commands
All commands should be used by opening terminal on the folder with files to be processed, and all commands apply to all corresponding files in that folder unless stated otherwise. None of them applies to any sub-folders. These commands are created for windows in mind, but it should be easy to convert them if you are using a linux distro. Just ask chatgpt to convert it.
Convert Webms to MP4 (folder bulk) ---- CLICK HERE TO SHOW/HIDE
Converts all *.webm files to *.mp4 files, keeps the webm files as well. This also fixes ´height is not divisible by 2´ errors and works with almost all webms.
There is a much faster method:
for %i in (*.webm) do ffmpeg -i "%i" -c copy "%~ni.mp4"
but this won't work for odd height or some webms with vp8 codec.Resize all mp4 files to a maximum width&height ---- CLICK HERE TO SHOW/HIDE
Below command will resize all mp4 files from current folder so their dimensions are not more than 800. You can replace both occurrences of "800" with any even number and it should work just fine:
New files will start with prefix "resized_".
Lower FPS for fast processing ---- CLICK HERE TO SHOW/HIDE
Below command will create an output folder and change fps of all mp4 files to 12. This usually means your files will be processed in, for example, 5 minutes instead of 15 or 25 minutes. You can change 12 to a better quality fps like 24 or 30.
See frame counts and fps of your video files ---- CLICK HERE TO SHOW/HIDE
This command will try to count frame numbers(actually it counts something else that is usually equal to the frame count) AND detects the fps of each video, file, and prints them out. It is helpful when you want to know how much time you will need to spend for each video, or if your videos can benefit from fps reduction.
Batch Files
There were some slightly more complex operations I solved using bat files. You can create .bat files for each one, place them in a folder called, idk, "myutils", and include that folder's path in your PATH environment variable. This will allow you to run them using only the file name on your terminal.
Quickly merge mp4 files ---- CLICK HERE TO SHOW/HIDE
If you end up using the Set as Start / End functionality of roop unleashed, you will probably need to merge those multiple sections into one video file. Just put your videos in a folder and run below command. It will create a list of file names(txt) and use it to run ffmpeg's concat (merge) feature:
Recursively resize video files ---- CLICK HERE TO SHOW/HIDE
This is very similar to the resize command I shared above, but it walks through sub-folders and runs the command for any mp4 or webm files it can read.
ROOPIFY - v1 ---- CLICK HERE TO HIDE/SHOW
This is a long batch file I am very proud of. Even tho it mostly fits my own requirements, you can still modify it a bit and use it for your own needs, if you find them to be similar.
Imagine you have a folder of lots of video files (mp4, m4s, m4k, webm).
This script first converts m4s and m4k files to mp4, then detects fps and frame count for each file.
if frame count is bigger than 1000, it decreases the fps value:
... if fps>58 ->change fps to 30.
... If fps>29, change it to 22.
... if fps>21, change it to 12
if frame count is bigger than 2000, it decreases fps even more aggressively:
... if fps>58 ->change fps to 22.
... If fps>29, change it to 12.
if the frame count is less than 1000, it doesn't change the fps value.
And finally, it renames all these files so that they are sorted by final frame count.
Example initial folder list:
Example end result:
roopify bat file content:
You can also create context menu items using these ones. I am using Shell, and have a video bulk process submenu like this one:
Beta Was this translation helpful? Give feedback.
All reactions