0

I'm trying to upload a video with a shareable link using Pydrive, but when I try to see the video using the link I get an error message: couldn't process the video.

I've tried with a small size video (7MB) and using different formats, such as MP4, WEBM, and MOV. But I get the same error. I wonder if you could help me. I really appreciate it.

Here is my code:

folderName = 'Videos'

folders = drive.ListFile({'q': "title='" + folderName + "' and mimeType='application/vnd.google-apps.folder' and trashed=false"}).GetList()
for folder in folders:
    if folder['title'] == folderName:
        folderId = folder['id']

import glob, os
os.chdir("C:/upload_recording/videos")
for file in glob.glob("*.webm"):
    with open(file,"r") as f:
        fn = os.path.basename(f.name)
        file_drive = drive.CreateFile({'title':fn,'parents': [{'id': folderId}], 'copyRequiresWriterPermission': True, 'writersCanShare': False})
        file_drive.Upload()
        file_drive.InsertPermission({
                        'type': 'anyone',
                        'value': 'anyone',
                        'role': 'reader'})
                               
files = drive.ListFile({"q": "'" + folderId + "' in parents and trashed=false"}).GetList()
for file in files:
    keys = file.keys()
    if file['shared'] and 'alternateLink' in keys:
        link = file['alternateLink']
    else:
        link = 'No Link Available. Check your sharing settings.'
        
    name = file['id']
    
    print('name: {}  link: {}'.format(name, link))
Sandra
  • 13
  • 4
  • In your script, the mimeType is not set at `drive.CreateFile({'title':fn,'parents': [{'id': folderId}], 'copyRequiresWriterPermission': True, 'writersCanShare': False})`. For example, when the mimeType is set, what result will you get? – Tanaike Sep 18 '20 at 23:34
  • @Tanaike you are right again, I forgot the mimetype:'video/mp4'. Is working now, just the video processing takes several minutes, but I have to be patient. Thank you :) – Sandra Sep 19 '20 at 04:37
  • Thank you for replying. I'm glad your issue was resolved. – Tanaike Sep 19 '20 at 08:30

1 Answers1

0

I forgot to define the mimetype (@Tanaike thank you):

drive.CreateFile({'title':fn, 'mimetype': 'video/mp4','parents': [{'id': folderId}], 'copyRequiresWriterPermission': True, 'writersCanShare': False})
Sandra
  • 13
  • 4