Skip to content

Design and Implement a Concatenate Interface #6

@Pedrexus

Description

@Pedrexus

The library currently lacks an intuitive method to concatenate or join multiple videos. A new interface, concatenate, needs to be designed and implemented to provide this functionality. Additionally, to make the operation more Pythonic and user-friendly, we should support the use of the __add__ magic method.

Proposed Interface:

1. Concatenate Method:

def concatenate(videos: List[Video]) -> Video:
    """
    Concatenate multiple video objects in the order they appear in the list.

    Args:
    - videos (List[Video]): A list of video objects to be concatenated.

    Returns:
    - Video: A new video object that represents the concatenated videos.
    """

Usage Example:

concatenated_video = Video.concatenate([video1, video2, video3])

2. Overload __add__ method:

The __add__ method should be implemented in the Video class to allow the use of the + operator for concatenating videos.

Usage Example:

concatenated_video = video1 + video2 + video3

Expected Outcome:

  • Users should be able to easily concatenate multiple video objects using the proposed concatenate method.
  • The + operator should concatenate video objects seamlessly, offering an intuitive and Pythonic way to join videos.

Additional Notes:

  • We need to ensure videos have the same resolution, frame rate, and other properties or decide how to handle discrepancies.
  • It would be good to add error handling for mismatched video properties or provide options to automatically adjust them.
  • We can do validation with the pydantic library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions