Compress videos with HandBrake CLI online in Google Colab. Get email notification when tasks finish running. You can use it for a single file or for a directory with lots of files. As we know any process in Colab can only run for 90 mins after closing the browser so in case of a batch convert/compress task it can remember the files which have already been processed so you can re-run the task again another time to finish the task (basically resume support).
Requirements
Basic knowledge of how to use colab notebooks and rclone.
To use email notifications only gmail id can be used and use an **app specfic password** Google account settings in order for the feature to work.
Mount cloud drive using rclone or with the google’s own gdrive mount method, though I would recommend rclone method as the latter could be unreliable sometimes.
Copy path to the Source file/directory with the help of the file browser.
Paste the copied path to the SOURCE text-field in the HandBrake Cell.
Paste path to the Destination in DESTINATION text-field. (Destination drive must be mounted beforehand)
For email notifications give your gmail id and app specific password and tick the checkbox.
Bugs so far
None discovered yet. Please mention here if you find any.
Note
If you have security concerns you can check the source code of the notebook here in my github repo and off-course you can skip this step if you don’t feel safe using it.
Words of thanks
(skip this if you don’t want to get bored LOL )
Firstly I would like to thank OneHack and all its wonderful members for sharing amazing content. I’ve learnt a lot from here and this small project is a testimony to that.
Few months ago FlashyFlash posted a google colab notebook (oneclickrun) and I was amazed by what all it could do so I wanted to make my own notebooks in colab but I didn’t know how to code, specifically Python.
Few days later after that SaM posted a free udemy course link which was the top rated course “Automate the Boring Stuff with Python Programming” from where I learnt Python programming.
This is my first project after learning Python (and also my first post). So special thanks to FlashyFlash and SaM for providing such awesome resources.
Disclaimer
This post is provided to help you and for personal use only. Sharing the content of your subscribed materials and the other purchased content is strictly prohibited under 1Hack Terms of Use.
By using this provided material the website 1Hack.us is not responsible for any law infringement caused by the users of this material.
bro there’s a mistake in your code, search for “f_name = fileName(currentPath)”
Here, it will accept SOURCE instead of currentPath, otherwise it doesn’t run and shows error. Please correct it because currentPath is setup later and hence can’t be used before defining it
thanks this is very useful and do share more colab scripts.
can yiu make all in one ffmpeg colab notebook?
you can add code for converting from video to audio mp3, converting a video to x265/x264, converting bluray to x264/x265, trimming audio video, taking screenshots from videos etc.
that is going to be massive hit for sure. take ur time
rclone is just a tool which allows you to transfer files between cloud drives( your team drive, google drive, onedrive or Mega.nz etc).
In Colab we need it to mount our cloud drives as a file system so that handbrake can read and write files to the drive.
In order to use it you need to first configure on your local machine which will generate a “rclone.conf” file. You only need to set it up once.
A short tutorial for windows users for configuring rclone:
Extract the downloaded file “rclone-v1.53.0-windows-amd64.zip”
Open command line in the extracted folder by typing “cmd” in the address bar.
type rclone config . It should output the below text:
No remotes found - make a new one
n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
n/r/c/s/q> n
Press n and hit enter to create a new remote.
(For this example I’ll configuring for a google drive)
type in any name for the remote . lets say “mygdrive” , hit enter
Now a list of supported cloud storage providers will show up . Choose a number associated with your cloud drive. Here google drive is 13 so we type 13 and hit enter.
It’ll now ask for Client ID: press enter to skip this for now to use default
Client secret: skip by hitting enter
Scope : press 1 for Full access all files, excluding Application Data Folder.
root folder id : skip by hitting enter
service_account_file : skip
Edit advanced config? : skip
Use auto config : press enter, it’ll open up google login page in your browser to give access to rclone.
Now after giving access , it’ll now ask “Configure this as a team drive?”
If you want to use it with your team drive type “y” otherwise hit enter and it’ll skip. I hit “y” for now.
Enter a team drive ID: It’ll now show list of team drives. choose your team drive and enter its number.
after that it’ll show the configuration. hit enter to confirm.
That’s it your team drive is configured to use it with rclone anywhere. You need to repeat the above steps to configure multiple cloud drives and it’ll get saved to rclone.conf
On Windows it is located in :
C:\Users<USERNAME>.config\rclone\rclone.conf
This is the file you need to upload in the 2nd cell Sorry for late reply guys
OSError Traceback (most recent call last)
<ipython-input-3-656e6abe01aa> in <module>()
84 pass
85 else:
---> 86 with open((SOURCE+'processed_db.txt'), 'w') as fb:
87 fb.write("Do not delete this file until all files have been processed!\n")
88 fb.close()
OSError: [Errno 30] Read-only file system:
getting this error while trying to convert a shared folder.