I am using Opencv Python version 4.1.2.30 for write image to video as mention in code but unfortunately when I run Script in Pycharm it run correctly but when I convert script to EXE from pyinstaller with PYQT5 its give me error like as below.
'
[ERROR:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap.cpp (392) cv::VideoWriter::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): Detected_video.avi in function 'cv::icvExtractPattern
pathIn = IMG_OUTPUT_FOLDER
image_interval = 1 # Interval between two images
fps = 1 / image_interval
files = video_df
frame_array = []
for i in range(len(files.index)):
img_name = files.loc[i, 'Image_Name']
filename = os.path.join(pathIn, img_name)
# reading each files
img = cv2.imread(filename)
height, width, layers = img.shape
size = (width, height)
# inserting the frames into an image array
frame_array.append(img)
os.chdir(VIDEO_OUTPUT_FOLDER)
out = cv2.VideoWriter("Detected_video.avi", cv2.VideoWriter_fourcc(*'DIVX'), fps, size)
for i in range(len(frame_array)):
# writing to a image array
out.write(frame_array[i])
out.release()
os.chdir(CWD_PATH)Only reason I can think of is that PyInstaller does not copy the FFmpeg dll during the packaging process.
If you have a look at e.g. ...Python37\Lib\site-packages\cv2 folder, there is something like opencv_videoio_ffmpeg412_64.dll next to cv2.cp37-win_amd64.pyd.
Does the opencv_videoio_ffmpeg412_64.dll file exist in the package which was created in PyInstaller? If not, add it to the spec file (binaries): https://pyinstaller.readthedocs.io/en/stable/spec-files.html#spec-file-operation
Hello, I do not know if you can explain a little more please, because I did not understand much, I have the same problem and try to apply the solution but I still get the same error.

opencv_videoio_ffmpeg412_64.dll file exist in the package which was created in PyInstaller
but still i get error
This is not PyInstaller support forum. Please open an issue to PyInstaller repository if you encounter issues with PyInstaller.
Check if the path to the video file is correct or files exist. This mistake appears when you try implement .shape to the empty frame Also it is possible if a variable was inited inside an internal function and you try to call it otside
Most helpful comment
Only reason I can think of is that PyInstaller does not copy the FFmpeg dll during the packaging process.
If you have a look at e.g.
...Python37\Lib\site-packages\cv2folder, there is something likeopencv_videoio_ffmpeg412_64.dllnext tocv2.cp37-win_amd64.pyd.Does the
opencv_videoio_ffmpeg412_64.dllfile exist in the package which was created in PyInstaller? If not, add it to the spec file (binaries): https://pyinstaller.readthedocs.io/en/stable/spec-files.html#spec-file-operation