# openshot/libopenshot architecture

> Architecture diagram of the GitHub repository openshot/libopenshot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openshot/libopenshot
- Repository: https://github.com/openshot/libopenshot

## Overview

##### Main Components

a. Core Library Components:
- Media Processing Core
- Reader Components (FFmpegReader, ImageReader, etc.)
- Writer Components (FFmpegWriter, ImageWriter, etc.)
- Frame Processing System
- Timeline Engine
- Effects Pipeline

b. Audio Subsystem:
- Audio Processing Core
- Audio Devices Management
- Audio Effects Processing
- Resampling Engine
- Waveform Generation

c. Hardware Acceleration Layer:
- GPU Acceleration Interface
- Multiple Backend Support (as mentioned in HW-ACCEL.md)

d. Language Bindings:
- Python Interface
- Ruby Interface
- Java Interface

e. Qt Integration:
- Video Playback System
- Qt Widget Integration
- Rendering Pipeline

**┌─────────────────────────────────────────────────────┐**
- Language Bindings                     │
- (Python, Ruby, Java Interface Layers)            │
- ┤
- Qt Integration                      │
- (Video Player, Widget Rendering, Playback)       │
- ┤
- Core Library Components               │
- ┬─────────────────┬─────────────────┤
- Media Pipeline│  Effects System │  Timeline Engine │
- Readers     │  - Video Effects│  - Compositing  │
- Writers     │  - Audio Effects│  - Animation    │
- Processors  │  - Filters      │  - Keyframes    │
- ┴─────────────────┴─────────────────┤
- Hardware Acceleration                  │
- (GPU Encoding/Decoding Support)             │
- ┤
- External Dependencies                 │
- (FFmpeg, ImageMagick, Audio Libraries)          │
- ┘

##### Important Details

a. Processing Flows:
- How media flows from readers through effects to writers
- Parallel processing paths
- Hardware acceleration points

b. Integration Points:
- How language bindings interface with the core
- Qt widget integration
- External library connection points

c. Caching System:
- Both memory and disk cache components
- Cache interaction with processing pipeline

##### Notes

- Version information
- Hardware acceleration as optional
- Threading model where relevant

- Layers
- Export to vector formats
- Easy updating and maintenance

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Language Bindings"
        PythonBinding["Python Binding"]:::binding
        RubyBinding["Ruby Binding"]:::binding
        JavaBinding["Java Binding"]:::binding
    end

    subgraph "Qt Integration"
        VideoPlayback["Video Playback"]:::qt
        WidgetIntegration["Widget Integration"]:::qt
        PlayerComponents["Player Components"]:::qt
        Rendering["Rendering"]:::qt
    end

    subgraph "Core Library"
        subgraph "Media Processing"
            Readers["Readers"]:::core
            Writers["Writers"]:::core
            FrameProcessing["Frame Processing"]:::core
            TimelineEngine["Timeline Engine"]:::core
        end

        subgraph "Audio System"
            AudioProcessing["Audio Processing"]:::audio
            AudioEffects["Audio Effects"]:::audio
            Resampling["Resampling"]:::audio
            WaveformGen["Waveform Generation"]:::audio
        end

        subgraph "Effects System"
            VideoEffects["Video Effects"]:::effects
            EffectsBase["Effects Base"]:::effects
            EffectsInfo["Effects Info"]:::effects
        end

        subgraph "Cache System"
            MemoryCache["Memory Cache"]:::cache
            DiskCache["Disk Cache"]:::cache
            BaseCache["Base Cache"]:::cache
        end
    end

    subgraph "Hardware Acceleration"
        GPUAccel["GPU Acceleration"]:::hw
    end

    subgraph "Core Utilities"
        FFmpegUtil["FFmpeg Utilities"]:::util
        OpenCVUtil["OpenCV Utilities"]:::util
        OpenMPUtil["OpenMP Utilities"]:::util
    end

    %% Relationships
    PythonBinding & RubyBinding & JavaBinding --> TimelineEngine
    VideoPlayback --> Rendering
    WidgetIntegration --> Rendering
    PlayerComponents --> VideoPlayback
    Readers --> FrameProcessing
    Writers --> FrameProcessing
    FrameProcessing --> TimelineEngine
    TimelineEngine --> VideoEffects
    AudioProcessing --> AudioEffects
    AudioEffects --> TimelineEngine
    Resampling --> AudioProcessing
    WaveformGen --> AudioProcessing
    VideoEffects --> EffectsBase
    EffectsInfo --> EffectsBase
    MemoryCache & DiskCache --> BaseCache
    GPUAccel --> FrameProcessing
    FFmpegUtil & OpenCVUtil & OpenMPUtil --> FrameProcessing

    %% Click Events
    click Readers "https://github.com/OpenShot/libopenshot/blob/develop/src/FFmpegReader.h"
    click Writers "https://github.com/OpenShot/libopenshot/blob/develop/src/FFmpegWriter.h"
    click FrameProcessing "https://github.com/OpenShot/libopenshot/blob/develop/src/Frame.h"
    click TimelineEngine "https://github.com/OpenShot/libopenshot/blob/develop/src/Timeline.h"
    click AudioProcessing "https://github.com/OpenShot/libopenshot/blob/develop/src/AudioBufferSource.h"
    click AudioEffects "https://github.com/OpenShot/libopenshot/tree/develop/src/audio_effects"
    click Resampling "https://github.com/OpenShot/libopenshot/blob/develop/src/AudioResampler.h"
    click WaveformGen "https://github.com/OpenShot/libopenshot/blob/develop/src/AudioWaveformer.h"
    click VideoEffects "https://github.com/OpenShot/libopenshot/tree/develop/src/effects"
    click EffectsBase "https://github.com/OpenShot/libopenshot/blob/develop/src/EffectBase.h"
    click EffectsInfo "https://github.com/OpenShot/libopenshot/blob/develop/src/EffectInfo.h"
    click PythonBinding "https://github.com/OpenShot/libopenshot/tree/develop/bindings/python"
    click RubyBinding "https://github.com/OpenShot/libopenshot/tree/develop/bindings/ruby"
    click JavaBinding "https://github.com/OpenShot/libopenshot/tree/develop/bindings/java"
    click VideoPlayback "https://github.com/OpenShot/libopenshot/blob/develop/src/Qt/VideoPlaybackThread.h"
    click WidgetIntegration "https://github.com/OpenShot/libopenshot/blob/develop/src/Qt/VideoRenderWidget.h"
    click PlayerComponents "https://github.com/OpenShot/libopenshot/blob/develop/src/Qt/PlayerDemo.h"
    click Rendering "https://github.com/OpenShot/libopenshot/blob/develop/src/Qt/VideoRenderer.h"
    click MemoryCache "https://github.com/OpenShot/libopenshot/blob/develop/src/CacheMemory.h"
    click DiskCache "https://github.com/OpenShot/libopenshot/blob/develop/src/CacheDisk.h"
    click BaseCache "https://github.com/OpenShot/libopenshot/blob/develop/src/CacheBase.h"
    click GPUAccel "https://github.com/OpenShot/libopenshot/blob/develop/doc/HW-ACCEL.md"
    click FFmpegUtil "https://github.com/OpenShot/libopenshot/blob/develop/src/FFmpegUtilities.h"
    click OpenCVUtil "https://github.com/OpenShot/libopenshot/blob/develop/src/OpenCVUtilities.h"
    click OpenMPUtil "https://github.com/OpenShot/libopenshot/blob/develop/src/OpenMPUtilities.h"

    %% Styles
    classDef core fill:#2374ab
    classDef audio fill:#7209b7
    classDef effects fill:#4cc9f0
    classDef cache fill:#fb8500
    classDef binding fill:#80b918
    classDef qt fill:#9b5de5
    classDef hw fill:#f15bb5
    classDef util fill:#fee440

    %% Legend
    subgraph Legend
        CoreComp["Core Components"]:::core
        AudioComp["Audio Components"]:::audio
        EffectsComp["Effects Components"]:::effects
        CacheComp["Cache Components"]:::cache
        BindingComp["Language Bindings"]:::binding
        QtComp["Qt Components"]:::qt
        HWComp["Hardware Components"]:::hw
        UtilComp["Utility Components"]:::util
    end
```
