# Convert your gdrive videos using google colab

**URL:** <https://onehack.st/t/convert-your-gdrive-videos-using-google-colab/90622>\
**Category:** Tools & Scripts\
**Created:** [June 7, 2020, 3:24pm UTC](https://onehack.st/t/convert-your-gdrive-videos-using-google-colab/90622 "2020-06-07T15:24:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leechr\_seedr](https://onehack.st/user_avatar/onehack.st/leechr_seedr/32/18487_2.png) [@Leechr\_seedr](https://onehack.st/u/Leechr_seedr)\
**Post date:** [June 7, 2020, 3:24pm UTC](https://onehack.st/t/convert-your-gdrive-videos-using-google-colab/90622/1 "2020-06-07T15:24:17Z")

</div>

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'

#print(listOfFolders)

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

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

print(" ***********************************")

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))]

  print(onlyfiles)

  for i in onlyfiles: 

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

      #print(i)

      i=i.replace("\'","")

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

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

      try:  

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

      except OSError as error:  

        print(error)   

      

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

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

      try: 

        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(error)         

    else:

      print("Files other than .mp4")

```

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

---

<div class="post-metadata">

**Author:** ![Adnan\_Catper](https://onehack.st/user_avatar/onehack.st/adnan_catper/32/18110_2.png) [@Adnan\_Catper](https://onehack.st/u/Adnan_Catper)\
**Post date:** [June 26, 2020, 5:35pm UTC](https://onehack.st/t/convert-your-gdrive-videos-using-google-colab/90622/2 "2020-06-26T17:35:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Samoo7](https://onehack.st/user_avatar/onehack.st/samoo7/32/1905_2.png) [@Samoo7](https://onehack.st/u/Samoo7)\
**Post date:** [June 27, 2020, 11:14am UTC](https://onehack.st/t/convert-your-gdrive-videos-using-google-colab/90622/3 "2020-06-27T11:14:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Samoo7](https://onehack.st/user_avatar/onehack.st/samoo7/32/1905_2.png) [@Samoo7](https://onehack.st/u/Samoo7)\
**Post date:** [June 27, 2020, 11:17am UTC](https://onehack.st/t/convert-your-gdrive-videos-using-google-colab/90622/4 "2020-06-27T11:17:05Z")

</div>

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

And your efforts are highly appreciated 👏 🤝

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

---

<div class="post-metadata">

**Author:** ![Harish\_Kumar](https://onehack.st/user_avatar/onehack.st/harish_kumar/32/27718_2.png) [@Harish\_Kumar](https://onehack.st/u/Harish_Kumar)\
**Post date:** [July 4, 2020, 11:13pm UTC](https://onehack.st/t/convert-your-gdrive-videos-using-google-colab/90622/5 "2020-07-04T23:13:17Z")

</div>

* * *

FileNotFoundError Traceback (most recent call last)  
 in ()  
13 print(“\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*”)  
14  
—\> 15 subfolders = list(filter(lambda x: os.path.isdir(os.path.join(filePath, x)), os.listdir(filePath)))  
16  
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

---

<div class="post-metadata">

**Author:** ![Leechr\_seedr](https://onehack.st/user_avatar/onehack.st/leechr_seedr/32/18487_2.png) [@Leechr\_seedr](https://onehack.st/u/Leechr_seedr)\
**Post date:** [July 18, 2020, 6:26am UTC](https://onehack.st/t/convert-your-gdrive-videos-using-google-colab/90622/6 "2020-07-18T06:26:17Z")

</div>

are you sure that course is present in your shared drive?  
Try to navigate to shared drive and update the path accordingly.
