[Python] how can i save a video produced with cv2.VideoWriter at Google-Colab to a Google...

Discussão em 'Python' iniciado por Stack, Setembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to somehow copy the "video1.mkv" at a folder called "my folder".


    There are better ways to copy but my tend is to read "video1.mkv" and create a new video by using the video that I've read before.
    ​

    The problem is that I cant save it!


    My codes are in Google-Colaboratory and I use Google-Drive as my directory for saving my files, codes or read anything from it. ' everything is available in the "my folder", include the "name.ipnb" that I am coding in it'
    ​

    So this is the code snippet:

    import cv2 as cv

    import os
    from google.colab import drive
    drive.mount('/content/drive')
    os.chdir('/content/drive/My Drive/my folder')

    caped = cv.VideoCapture('video1.mkv')


    Start of problems:

    x = cv.VideoWriter('./video2', cv.VideoWriter_fourcc(*'XVID'), 3, (600, 500))

    while(caped.isOpened()):

    ret, frame = caped.read()

    if ret == True:
    x.write(frame)

    else:
    break


    caped.release()
    x.release()


    there is not any error raised but "video2" won't save!
    ​

    Continue reading...

Compartilhe esta Página