Convert your gdrive videos using google colab

This script may help people having less bandwidth but having large tutorial videos on their shared drive.

Below python (google colab) script converts your videos and store them on gdrive itself.

In my case tutorial videos are saved on shared drive and after conversion its saved into my personal gdrive.

After conversion 90mb files gets reduced to 12mb file.

import numpy as np

import os

#listOfFolders = !ls '/content/drive/Shared drives/Tutorials | Product of Web Premium. Pw/Learn Complete Python In Simple Way'


#listOfFilesInsideFolder = !ls '''/content/drive/My Drive/Torrent/Python/3. Python Basics'''

filePath ='''/content/drive/Shared drives/learning/UDEMY/python-tutorials-for-by-navinreddy/'''


subfolders = list(filter(lambda x: os.path.isdir(os.path.join(filePath, x)), os.listdir(filePath)))

for j in  subfolders:

  from os import listdir

  from os.path import isfile, join

  onlyfiles = [f for f in listdir(filePath+j+'''/''') if isfile(join(filePath+j+'''/''', f))]


  for i in onlyfiles: 

    if i.endswith('''.mp4'''):



      src = filePath+j+'''/'''+i

      print("Source is --->",src)


        os.mkdir('''/content/drive/My Drive/python/'''+j) 

      except OSError as error:  



      dest = '''/content/drive/My Drive/python/'''+j+'''/'''+i

      print("Destination is --->",dest)


        os.system('''ffmpeg -i '%s' -s 720x480 -ar 44100 -async 44100 -r 29.970 -ac 2 -qscale 5 '%s' ''' %(src, dest) )

      except OSError as error:  



      print("Files other than .mp4")

p.s. I am python beginner… so pardon me if any silly mistakes. Better approaches are always welcome.


it seems a good script, but would you explain how videos will be converted and what will be output file media info?

@Adnan_Catper - File: MP4 / Res: 720x480 / FR: 29.970

But it’ll turn down the resolution bro like if video is 1080p after your script its 720x480

And your efforts are highly appreciated :clap: :handshake:

try to write for more codecs hope you can understand what i mean

FileNotFoundError Traceback (most recent call last)
in ()
13 print("***********************************")
—> 15 subfolders = list(filter(lambda x: os.path.isdir(os.path.join(filePath, x)), os.listdir(filePath)))
17 for j in subfolders:

FileNotFoundError: [Errno 2] No such file or directory: ‘/content/drive/Shared drives/learning/UDEMY/python-tutorials-for-by-navinreddy/’

I am getting this error Friend

Friendly Websites