abhiTronix/vidgear

[Bug]: WriteGear().write causes python process to terminate

Closed this issue · 3 comments

Description

The write method causes my entire python to crash:
Process finished with exit code -1073741819 (0xC0000005)

I use generator function to iteratively write images to a file with WriteGear.
The exception is never reached. The process just terminates.

Details in description below.

Would be awesome if somebody could look into it.
Thank you.

Issue Checklist

  • I have searched open or closed issues for my problem and found nothing related or helpful.
  • I have read the Documentation and found nothing related to my problem.
  • I've read the Issue Guidelines and wholeheartedly agree.

Expected behaviour

Writer writes to the file.

Actual behaviour

The write method causes my entire python to crash:
Process finished with exit code -1073741819 (0xC0000005)

Steps to reproduce

The write method causes my entire python to crash:
Process finished with exit code -1073741819 (0xC0000005)

I use generator function to iteratively write images to a file like:

output_params = {"-input_framerate": frame_rate}  # ffmpeg params
writer = WriteGear(output=save_path, compression_mode=True, **output_params)
for img in image_generator:
       try:
            if not isinstance(img, np.ndarray):
                raise ValueError("The image generator should yield images as numpy arrays or filepaths.")
            writer.write(img)
        except Exception as e:
            print(f"Error writting: {e}. Skipping frame")

However the writer.write(img) function causes the problem at line 430:

try:
   # try writing the frame bytes to the subprocess pipeline
     self.__process.stdin.write(frame.tobytes())
except (OSError, IOError):
     # log if something is wrong!
        logger.error(
          "BrokenPipeError caught, Wrong values passed to FFmpeg Pipe. Kindly Refer Docs!"
         )
        raise ValueError  # for testing purpose only

The exception is never reached. The process just terminates.

I found a related problem on Stack Overflow, but was not able to resolve the problem by myself.
If i use cv2.imwrite("problem_frame.png", frame) the image turns out normal.

Would be awesome if somebody could look into it.
Thank you.

Terminal log output

No response

Python Code(Optional)

No response

VidGear Version

0.3.3

Python version

3.8

OpenCV version

4.8

Operating System version

Windows

Any other Relevant Information?

No response

Thanks for opening this issue, a maintainer will get back to you shortly!

In the meantime:

  • Read our Issue Guidelines, and update your issue accordingly. Please note that your issue will be fixed much faster if you spend about half an hour preparing it, including the exact reproduction steps and a demo.
  • Go comprehensively through our dedicated FAQ & Troubleshooting section.
  • For any quick questions and typos, please refrain from opening an issue, as you can reach us on Gitter community channel.

Hey @w4hns1nn, Could you please enable verbose logging by running WriteGear with logging=True? Once you've done that, share the full terminal output here, up to the point where you encounter the bug. Thanks!

Hey abhiTronix! First of all thank you very much for responding; this is honorable!
Well this morning I uninstalled ffmpg and reinstalled it; rebootet my computer and after the error disappeared.
Misterious, however I hope I can help somebody else to resolve the issue with the answer.

I'm sorry that we can't look deeper into the issue, because obviously there's deeply nested a bug :D

I closed the report.
Thanks anyway