Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove video clip after frame extraction #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

skrashevich
Copy link
Contributor

Modified the download_video_clip_and_extract_frames function in mqtt_client.py to delete the downloaded video clip after the frames have been extracted. This change helps to manage disk space by removing unnecessary files after they have been processed.

Modified the download_video_clip_and_extract_frames function in mqtt_client.py to delete the downloaded video clip after the frames have been extracted. This change helps to manage disk space by removing unnecessary files after they have been processed.
This commit wraps the video clip saving and frame extraction process in a try-except block to handle potential OSError exceptions. If an OSError occurs, an error message is logged and an empty list of frames is returned. This prevents the program from crashing when there's an issue with saving the video clip.
Copy link
Owner

@mhaowork mhaowork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. I am not a Python expert. I saw that a Python idiom way is to use with context to enclose the tempfile operations and then the temp files should get cleaned up automatically.

https://docs.python.org/3/library/tempfile.html#tempfile.TemporaryDirectory

@skrashevich
Copy link
Contributor Author

temp files should get cleaned up automatically.

... on system reboot :)

@mhaowork
Copy link
Owner

temp files should get cleaned up automatically.

... on system reboot :)

I thought it is once exiting the with context?

"On completion of the context or destruction of the temporary directory object, the newly created temporary directory and all its contents are removed from the filesystem."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants