-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
NOTE: This is different from #89, because that is just a workflow improvement.
This feature is about running the exact same operation (or cut) on multiple files, e.g. you have a folder with a number of files, and you want to do the exact same thing with all files.
Such a feature could be implemented by having an extra "Tools" menu or an option in the Export dialog where the user selects additional files to run the same edit on. Or the operation could be done on all files the currently loaded batch list.
Note that I haven't prioritised this very highly, because there are so many different wishes and these kinds of operations can often be easily automated by bash scripting using ffmpeg directly (even with the help of AI, see workaround below)
Batch same cut on multiple files
- Run the same cut operation on multiple files Perform batch cutting of files for a fixed time of minutes and seconds from the list #2011
- split all files into segments of length X Perform batch cutting of files for a fixed time of minutes and seconds from the list #2011 (comment)
This might done on be all files in the "batch list".
Other batch operations
- Batch same rotation How to apply rotation 270 degree of batch list ? #899
- Batch change format and remove tracks Batch process from multiple video files workflow (different cuts) #89 (comment)
- Maybe it's an idea for LosslessCut to be able to capture the outputted ffmpeg commands from an operation and re-run them on a list of files.
- Batch fix incorrect duration Add "fix incorrect duration" to batch operations #1276
- Batch extracting of (audio or video or all) tracks Batch extracting of (part of) all tracks #1554
Grouped batching
- Smart batch/multiple Merge "groups" of files Smart batch/multiple Merge "groups" of files #812
Workaround: bash script
See also Batch processing article
A simple workaround is to write a bash script and use ffmpeg
directly. For example to cut multiple files exactly the same, create a file batch.sh
with this content:
# example: cut away 30 sec from start of all files, and include everything until 60 sec
# adjust the following values:
TIME_TO_CUT_FROM=30
TIME_TO_CUT_TO=60
FOLDER_PATH=/path/to/files/*.mp4
for FILE in "$FOLDER_PATH"
do
# This ffmpeg command can be replaced with whichever operation you'd like to run on all the files.
# It could also be an ffmpeg command copy-pasted from LosslessCut (and adjusted)
ffmpeg -ss "$TIME_TO_CUT_FROM" -i "$FILE" -t "$TIME_TO_CUT_TO" -c copy "$FILE-cut.mp4"
done
Note that the example script above is for UNIX based operating systems like MacOS/Linux. Windows users: If you need to do this on Windows, maybe you can ask ChatGPT something like: "Convert this command from bash to Windows Batch" and paste the above command. Or you can use WSL2.
Tip: First run your desired operation (e.g. a cut) in LosslessCut on your first file in your batch list. Then open then "Last ffmpeg commands" menu, and look at the last ffmpeg command that was run. Then copy this and paste it into the above script. You then need to insert variables like $TIME_TO_CUT_FROM
, $TIME_TO_CUT_TO
and $FILE
into the command you copy pasted.
Bonus: ChatGPT / AI
I wish more people were aware of this, but large language models like ChatGPT can be incredibly useful for helping non-programmers with simple programming tasks.
Basically you just need to ask the AI to write a script for you to do whatever you need. If it doesn't work, you can continue the conversation to try to get it corrected. And it's free!
Here are a few examples:
Batch split files into equal length segments
write a bash script that takes a folder of mp4 files, then for each file, split it into an (unknown) number of files, each file of an equal length of 299 seconds.
This gave me the following script: #2011 (comment)
Batch rotate all files to 90 degrees
write a bash script that takes a folder of mp4 files, then for each file, losslessly change the rotation to 90 degrees and output to the same folder.
You know the drill now...
Then once you have the script, you can ask ChatGPT "how do I run this?"