warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545) python cmd call

asked 2015-02-14 08:28:34 -0600

Woody247 gravatar image

updated 2015-02-14 08:31:26 -0600

Hi guys,

I am getting this error when running the following code through LabVIEW which is interacting with Python through the cmd line.

import cv2   
import sys

#argv 0 = This py code   
cap = cv2.VideoCapture(sys.argv[1])  
print sys.argv[1]   
new = sys.argv[2]   
print new  

if cap.grab() == True:
    fourcc = cv2.cv.CV_FOURCC('C','V','I','D')

    fps = int(cap.get(5))
    width = int(cap.get(3))
    height = int(cap.get(4)) 

    out = cv2.VideoWriter(new,fourcc, fps, (width,height))

    delay = int(1000/fps)#delay in s

    num = int(cap.get(7)) #number of frames
    z = float(0.0)

    for k in range(1,num):
        ret, frame = cap.read()

        z += 1
        percent = float((z/num)*100)
        out.write(frame)#write flipped frame

        print percent
        cv2.waitKey(1)

    cap.release()
    out.release()

I am calling it using a LabVIEW code but effectively I'm just giving a filename to convert from mp4 to AVI.

Any help appreciated.

Woody

edit retag flag offensive close merge delete

Comments

it basically means, that your videocapture could not be opened, either, because the file-path was wrong, or because the codec was not supported.

berak gravatar imageberak ( 2015-02-14 08:53:35 -0600 )edit