Skip to content

Handled POSIX path to video directories in split_video_frames #192

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AshAnand34
Copy link
Contributor

This pull request refactors the split_video_frames function in autodistill/helpers.py to enhance its functionality and improve code clarity. The function now supports processing both individual video files and directories containing multiple video files, while also replacing the use of external utilities with direct OpenCV operations for frame extraction.

Enhancements to split_video_frames:

  • The function now accepts a directory of video files in addition to a single video file, automatically processing all supported video formats (.mp4, .mov, .avi, .mkv) in the directory.
  • Replaced the previous use of sv.list_files_with_extensions and sv.get_video_frames_generator with OpenCV's VideoCapture for frame extraction, providing more direct control over the process.
  • Frames are saved with a consistent naming pattern, including the base name of the video and a zero-padded index, ensuring clarity and uniqueness in the output directory.
  • Added support for creating the output directory if it does not already exist, improving usability.

Related Issue: #179

Copy link
Member

@capjamesg capjamesg left a comment

Choose a reason for hiding this comment

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

This is a useful change. Nice work! Please make the requested change and I'll review again.


if os.path.isdir(video_path):
# Process all video files in the directory
video_files = [
Copy link
Member

Choose a reason for hiding this comment

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

Can we still use the supervision function to get video paths?

    video_paths = sv.list_files_with_extensions(
        directory=video_path, extensions=["mov", "mp4", "MOV", "MP4"]
    )

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.

2 participants