Skip to content

pranayreddyambati/automated_clips_sampler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Video Sampling System

This project implements a video sampling system using Flask as an API to process and sample video clips. The system offers two distinct methods for video sampling: Traditional Sampling and Dynamic Sampling.

Table of Contents

Overview

The video sampling system provides an automated and efficient way to generate diverse samples from input videos. The implementation includes two methods, Traditional Sampling and Dynamic Sampling, each offering unique advantages based on user requirements.

Methods

Traditional Sampling

Method 1 involves processing all video clips in the initial step and then randomly selecting clips based on the specified sample percentage. The clips are then placed into a randomly chosen folder, and a final renaming process ensures sequential numbering.

Dynamic Sampling

Method 2 adopts a dynamic sampling approach, collecting information about individual video clips first. Random sampling is then directly applied to this collected information, enhancing efficiency, especially with large video datasets. This method allows for targeted and flexible selection.

Modules Used

  • Operating System (os) Library:
    • os.path.exists: Checks if a specified path exists.
    • os.path.join: Joins paths for folder creation and file handling.
    • os.makedirs: Creates folders for storing processed video clips.
    • os.listdir: Lists files in a directory for various operations.
    • os.rename: Renames video clips during the final renaming step.
  • File Operations (shutil) Library:
    • shutil.copy: Copies sampled video clips to a designated folder.
    • shutil.move: Moves sampled video clips to their final destination during the renaming process.
  • Regular Expressions (re) Library:
    • re.split: Applied in parsing clip names to extract relevant details, aiding in the systematic organization and naming of sampled video clips.
  • Flask Library:
    • Flask.request: Handles the incoming request data.
    • Flask.jsonify: Converts the result to a JSON response.
  • random Library:
    • random.sample: Randomly selects video clips based on a specified percentage.
  • VideoFileClip Class (from moviepy Library):
    • VideoFileClip.subclip: Extracts a subclip from the original video based on start and end times.
    • VideoFileClip.write_videofile: Writes the trimmed clip to a specified output path with specified codec and parameters.

How to Use

API Endpoint

The system provides a Flask-based API with the endpoint /process_and_sample. This endpoint receives POST requests from the frontend application to initiate the video processing workflow.

Input Parameters

To use the API, provide the following input parameters:

  • input_paths: Comma-separated paths of input videos.
  • output_path: Path to the output directory.
  • clip_length: Duration of each sampled video clip.
  • fps: Frames per second for video processing.
  • sample_percentage: Percentage of clips to be sampled.

For a successful request, ensure all critical parameters are included. Refer to the specific method details for additional considerations.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages