Unable to open the output.mp4 file using vlc or Quick time player in MAC OS Mojave : Duration of file is 00:00

asked 2019-09-24 23:50:06 -0600

updated 2019-09-25 03:33:19 -0600

supra56 gravatar image

Code:

 import cv2

videocapture = cv2.VideoCapture('SampleVideo.mp4')

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.mp4', fourcc, 20.0, (640,480) )

while(videocapture.isOpened()):
    v1, video1 = videocapture.read()

    if v1 == True:
        gray = cv2.cvtColor(video1, cv2.COLOR_BGR2GRAY)

        print(videocapture.get(cv2.CAP_PROP_FRAME_WIDTH))
        print(videocapture.get(cv2.CAP_PROP_FRAME_HEIGHT))

        cv2.imshow('frame', gray)

        if cv2.waitKey() == ord('q'):
            break
    else:
        break

out.release()
videocapture.release()
cv2.destroyAllWindows()
edit retag flag offensive close merge delete

Comments

1

please read doc and try samples. tutorial : how to read and write a video

LBerger gravatar imageLBerger ( 2019-09-25 03:39:09 -0600 )edit

@sukanyar. out.write is missing. You cannot put inside if/else condition block print, imshow and waitkkey Use @LBerger link.

supra56 gravatar imagesupra56 ( 2019-09-25 04:56:56 -0600 )edit

I tried using the program to save the video from the documentation - https://docs.opencv.org/master/dd/d43... and i still get the same issue , duration shows 00:00. Tried saving different formats still thes ame issue.

sukanyar gravatar imagesukanyar ( 2019-09-25 09:14:22 -0600 )edit

I referred to this youtube video to learn. The only difference that i see is that i am using mac os. I tried using quicktime player and vlc both and also tried different files mp4, avi. All provides me with the same result.

sukanyar gravatar imagesukanyar ( 2019-09-25 09:30:45 -0600 )edit

You can't convert from *XVID to mp4

supra56 gravatar imagesupra56 ( 2019-09-26 12:21:49 -0600 )edit