Skip to content

kdenlive

The kdenlive command facilitates video editors by generating XML files compatible with kdenlive settings, focusing specifically on automating the process of cutting silences from video timelines. This utility is especially designed to expedite the editing workflow, allowing users to jumpstart their projects with silences already trimmed, effectively eliminating one of the most time-consuming and tedious aspects of video editing.

โš ๏ธ Instability Alert: The interface for the kdenlive command is currently unstable. Users should anticipate potential modifications in future updates.

Main Features:

  • Automatic Silence-Cut Generation: VMH harnesses the silences command's capabilities to detect silent portions in your audio file. These detected silences are then converted into kdenlive-compatible XML cut instructions, effectively pre-empting the need for manual audio silence trimming.

  • Efficient XML Creation for Kdenlive: This command abstracts away the complexities of kdenlive's XML structure. Instead of fumbling with XML details, users can generate the required XML content for their timelines swiftly and effortlessly.

  • Fine-Tuned Silence Detection: Video editors can customize the silence detection parameters to suit their specific requirements:

  • --silence-time: Sets the minimum duration for a segment to be recognized as silence.
  • --threshold: Determines the decibel level to qualify a segment as silent.
  • --distance: Adjusts the granularity of silence detection, with options from short intervals to exact durations.

Sample Commands:

  1. For an automated silence-trimmed XML setup using audio.wav, video.mp4, and project.xml:

    vmh kdenlive project.kdenlive video.mp4
    
  2. Customizing silence detection parameters for the XML generation:

    vmh kdenlive project.kdenlive video.mp4 --silence-time 500 --threshold -30
    
  3. Using equilized audio

    vmh kdenlive project.kdenlive video.mp4 audio.mp3
    

--help Option Display:

A snapshot of available options and arguments for the kdenlive command:

$ vmh kdenlive --help

 Usage: vmh kdenlive [OPTIONS] INPUT_XML VIDEO_FILE [OUTPUT_PATH] [AUDIO_FILE]         

 Generates an XML compatible with kdenlive settings.                                   
 Note: It doesnโ€™t directly modify kdenlive files. It new kdenlive file with            
 [OUTPUT_FILE].                                                                        

โ•ญโ”€ Arguments โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ *    input_xml        PATH           [default: None] [required]                     โ”‚
โ”‚ *    video_file       PATH           [default: None] [required]                     โ”‚
โ”‚      output_path      [OUTPUT_PATH]  [default: cuts.kdenlive]                       โ”‚
โ”‚      audio_file       [AUDIO_FILE]   Optional audio equilized audio file            โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ•ญโ”€ Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ --silence-time  -s                INTEGER                  Minimal time in ms for   โ”‚
โ”‚                                                            configure a silence      โ”‚
โ”‚                                                            [default: 400]           โ”‚
โ”‚ --threshold     -t                INTEGER                  Value in db for detect   โ”‚
โ”‚                                                            silence                  โ”‚
โ”‚                                                            [default: -65]           โ”‚
โ”‚ --distance      -d                [negative|tiny|small|me  Distance betweet         โ”‚
โ”‚                                   dium|large|huge]         silences                 โ”‚
โ”‚                                                            [default: tiny]          โ”‚
โ”‚ --force             --no-force                             Ignore cache             โ”‚
โ”‚                                                            [default: no-force]      โ”‚
โ”‚ --help                                                     Show this message and    โ”‚
โ”‚                                                            exit.                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

API for developers

Source code in videomaker_helper/kdenlive.py
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
def cut(
    audio_file: Path,
    video_file: Path,
    input_file: Path,
    output_path: Path,
    silence_time,
    threshold: int,
    force: bool,
    distance: Literal[
        'negative',
        'tiny',
        'small',
        'medium',
        'large',
        'huge',
    ] = 'tiny',
) -> Path:
    if audio_file != Path(getcwd()):  # Typer don't support Path | None
        times = detect_silences(
            str(audio_file),
            silence_time,
            threshold,
            distance,
            force=force,
        )
    else:
        times = detect_silences(
            str(video_file),
            silence_time,
            threshold,
            distance,
            force=force,
        )

    chain_id, file_id, playlist = check_chain(video_file, input_file, 0)

    _output_path: str = kdenlive_xml(
        str(input_file),
        playlist_id=playlist,
        property_id=file_id,
        chain_id=chain_id,
        cuts=times,
        output_path=str(output_path),
    )
    logger.info(f'Video playlist {playlist}')

    chain_id, file_id, playlist = check_chain(video_file, input_file, 1)
    kdenlive_xml(
        _output_path,
        playlist_id=playlist,
        chain_id=chain_id,
        property_id=file_id,
        cuts=times,
        output_path=_output_path,
    )
    logger.info(f'Audio playlist {playlist}')

    if audio_file != Path(getcwd()):  # Typer don't support Path | None
        chain_id, file_id, playlist = check_chain(audio_file, input_file)
        kdenlive_xml(
            _output_path,
            playlist_id=playlist,
            chain_id=chain_id,
            property_id=file_id,
            cuts=times,
            output_path=_output_path,
        )
        logger.info(f'Audio playlist {playlist}')

    return Path(_output_path).resolve()