A few months ago, I created my YouTube channel, where I post content related to programming and technology. To edit my videos, I had no option but to use Final Cut Pro X, because of my low spec 13 inch 2015 MacBook Pro. It’s crazy to edit extensive projects in that machine.
Final Cut is amazing, and it is best for low spec devices like mine. The only problem is, it eats up memory like I eat chocolate truffle cake, and before the project is over, memory is. Each of my projects takes around 50 to 70 Gigabytes.
I obviously use an external SSD but it is not enough. After around 15 projects, it is over and you don’t want to delete your older projects.
Little About the File Structure of Final Cut Pro X
To edit a video, you need to first create a library. Each library comes with an event, and you can create more events if you need it. To work on the project, you must import your media and all the necessary files.
Import creates a folder called transcoded media inside of .fcpbundle file. To view it, right-click on the .fcpbundle file and go inside the event folder. Inside the event folder, there will be an original media folder, render files folder, and transcoded media folder.
The original media folder has aliases to the original files, the render files folder is created when you change the timeline in Final Cut, and the transcoded media folder is a copy of the original media, but it optimizes files for Final Cut Pro.
We can safely delete the render files folder, and the transcoded media folder as it is can be again generated once you open the project in Final Cut. These two folders take most of the space in your project.
Note:- Do not delete the transcoded media folder if the original media is not inside the same root project folder. This is because Final Cut uses transcoded media in the timeline. If you delete it and Final Cut cannot find original media, your project will get destroyed. If you don’t know what you are doing, remove this part
or each == “Transcoded Media”in line 24 from the code below.
Here is the Solution
There are two ways of doing it.
You can either do it manually or create a program to do it. If you have an enormous project with many events in a library, it can get tedious to go inside each project and delete every single render files folder, and the transcoded media folder. So, I created a program to do it for me.
import os import sys import shutil arguments = sys.argv f = arguments def get_size(start_path = '.'): total_size = 0 for dirpath, dirnames, filenames in os.walk(start_path): for f in filenames: fp = os.path.join(dirpath, f) try: total_size += os.path.getsize(fp) except FileNotFoundError: print(end = "") return total_size initial = round((float(get_size(f)) / 1073741824.0),3) for root, directories, files in os.walk(f): for each in directories: if each == "Render Files": # add this to remove transcoded media-> or each == "Transcoded Media" delete = str(os.path.join(root,each)) shutil.rmtree(delete, ignore_errors=True) final = round((float(get_size(f)) / 1073741824.0),3) difference = round(initial - final,3) print() print() print() for i in range(50): print("+", end = "") print() print("| INITIAL: " + str(initial) + " GB |") print("| FINAL: " + str(final) + " GB |") print("| SAVED: " + str(difference) + " GB |") for i in range(50): print("+", end = "")
First, we import the required libraries:
**os to access folders, `sys
** to read command-line arguments, andshutil` to delete the folders.
**def get_size() **function walks through all the files in a directory using
[os.walk](docs.python.org/3/library/os.html) and calculates their size. The function returns the total size of the folder.
Now we need to delete the render files and transcoded media folder. To do so, we again go through each folder in the main folder and check if it matches. If it does,
[shutil.rmtree()](docs.python.org/3/library/shutil.html) command deletes it.
Finally, we again calculate the size of the folder to calculate the difference. We then print the initial size and the final size of the folder with their difference using the fancy print statement.
How to use it
Open terminal and type
python3, drag the code here, and press space. Now drag the folder where you keep all your projects, and press enter. That’s it! You will be something like this in your terminal.
Screenshot from computer
Enjoy the extra memory. If you know a better way of doing it or encounter any issues, please let me know.