FFmpeg Media Tools — Video/Audio Workflow

Praat front-end for twelve FFmpeg video/audio operations. Replace audio, cut segments, generate waveform/spectrogram videos, burn subtitles, convert to HAP, and more — all from a single folder containing ffmpeg and your media files.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 1.1 (2026) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script provides a Praat front-end for FFmpeg — the swiss army knife of multimedia processing. Point the script to a folder containing ffmpeg (or ffmpeg.exe) and your input files, and choose from twelve operations. All paths are resolved automatically, and output files are written to the same folder with descriptive suffixes. The full FFmpeg command is printed to the Info window for transparency and educational purposes.

Why FFmpeg from Praat? Praat excels at audio analysis and synthesis, but video manipulation (extracting audio, cutting, subtitle burning, format conversion) requires external tools. This script bridges that gap: you stay inside Praat while FFmpeg handles the video heavy lifting. Perfect for creating stimuli for experiments, generating waveform videos for presentations, or integrating Praat-processed audio back into video files.

Supported operations (12 total):

1 Replace audio in video
2 Extract audio → open in Praat
3 Cut video (no re-encode)
4 Waveform video from audio
5 Spectrogram video from audio
6 Export Praat selection as video
7 Still image + audio → video
8 Add soft subtitles (mov_text)
9 Burn subtitles (hardcode)
10 Convert to HAP (Max/Jitter)
11 Change frame rate
12 Analysis contact video
FFmpeg download: Place ffmpeg (macOS/Linux) or ffmpeg.exe (Windows) in the same folder as your input files.

Quick start

  1. Create a folder with ffmpeg (or ffmpeg.exe) and your input media files (video, audio, image, subtitle).
  2. In Praat, run Media_ffmpeg_tools.praat.
  3. Enter the folder path (use forward slashes: C:/ffmpeg_folder or /Users/name/videos).
  4. Select an operation (1–12).
  5. Adjust operation-specific parameters (cut times, dimensions, frame rate, etc.).
  6. Enable Dry_run to preview the FFmpeg command without executing.
  7. Click OK — FFmpeg runs, output appears in the same folder, and operation 2/6 load results into Praat automatically.
Quick tip: Use Dry_run = yes first to see the exact FFmpeg command. This is great for learning FFmpeg syntax or debugging. For operation 6 (export Praat selection), a Sound must be selected beforehand. For operation 2 (extract audio), the extracted WAV loads automatically into Praat.
Important: FFmpeg must be placed inside the same folder as your input files — the script does not search system PATH. On Windows, use forward slashes in the folder path (e.g., C:/ffmpeg). Operation 3 (cut video) uses stream copy and is NOT frame-accurate — FFmpeg seeks to the nearest keyframe before the requested start time. For frame-accurate cuts, use operation 6 instead.

12 Operations — Detailed Reference

Operation 1: Replace audio in video

Takes a video file (mp4/mov/avi) and an audio file (wav/mp3/aiff), replaces the video's audio stream with the new audio. Video stream is copied (no re-encoding). Output: video_replaced_audio.mp4.

Flag: Shortest_stream — if enabled, the output duration matches the shorter of video or audio.

Operation 2: Extract audio from video → open in Praat

Extracts audio track from a video file, converts to WAV (16-bit PCM) at the specified sample rate and channel count. After extraction, the script automatically loads the WAV into Praat as a Sound object.

Parameters: Sample_rate (48000 default), Channels (Mono/Stereo).

Operation 3: Cut video without re-encoding (stream copy)

Cuts a video segment using start time and end time (or duration). Uses -c copy — no re-encoding, extremely fast but cuts at nearest keyframe (not frame-accurate). Output: video_cut.mp4.

Time formats: HH:MM:SS.mmm (e.g., 00:01:30.500) or SS.mmm (e.g., 90.5).
Use_duration_not_end: If enabled, the End_time field is treated as duration (e.g., 00:00:10 = 10 seconds from start).

Operation 4: Waveform video from audio

Generates a video showing a real-time waveform visualization of the audio. Uses FFmpeg's showwaves filter (line mode). Output: audio_waveform.mp4.

Parameters: Width/Height (1920×1080 default), Frame_rate (30 fps default).

Operation 5: Spectrogram video from audio

Generates a video showing a scrolling spectrogram of the audio. Uses showspectrum filter with combined mode, log scale, intensity coloring. Output: audio_spectrogram.mp4.

Parameters: Width/Height, Frame_rate.

Operation 6: Export Praat selection as video segment

The most powerful integration: (a) cuts a video segment using start/end times, (b) exports the selected Praat Sound's time range as a WAV, (c) optionally replaces the cut video's audio with the Praat-processed WAV. Requires exactly one Sound selected.

Parameters: Start_time, End_time, Replace_audio_in_cut (yes/no).

Operation 7: Still image + audio → video

Creates a video from a single image (jpg/png) and an audio file. The image is shown for the entire duration of the audio (video length = audio length). Output: audio_image_video.mp4.

Operation 8: Add soft subtitles (mov_text, MP4)

Adds subtitles as a separate stream (mov_text format) without burning into video. Subtitles can be toggled on/off in players. Output: video_subtitled.mp4.

Supported subtitle formats: .srt, .ass, .ssa.

Operation 9: Burn subtitles into video (hardcode)

Renders subtitles directly onto the video frames (hardcoded/burned in). Subtitles are always visible. Output: video_hardcoded.mp4.

Windows path note: FFmpeg's subtitles= filter requires colon escaping on Windows (C:/path → C\:/path). The script handles this automatically.

Operation 10: Convert video to HAP (Max/MSP / Jitter)

Converts video to HAP codec (popular in Max/MSP, Jitter, TouchDesigner). HAP is GPU-accelerated for real-time playback. Output: video_hap.mov.

Hap_mode: hap (standard), hap_alpha (with alpha channel), hap_q (quality variant).

Operation 11: Change video frame rate

Changes video frame rate using FFmpeg's fps filter. Frames are dropped or duplicated as needed. Output: video_fps25.mp4.

Target_fps: positive integer (e.g., 25, 30, 60).

Operation 12: Analysis contact video

Generates a "contact microphone" style visualization — point-to-point waveform that resembles a seismograph or contact mic signal. Uses showwaves with mode=p2p (point-to-point) and cyan color. Output: audio_contact.mp4.

Parameters: Width/Height, Frame_rate.

Integrated Workflows (A/B/C)

Workflow A: Video → Praat audio processing → replace audio

  1. Operation 2: Extract audio from video → opens in Praat.
  2. Process the audio in Praat (filter, transform, analyze, etc.).
  3. Save the processed audio as WAV (or keep in memory).
  4. Operation 1: Replace audio in video using the original video + processed WAV.

Result: New video with Praat-processed audio, all other streams unchanged.

Workflow B: Praat audio → waveform/spectrogram video → presentation

  1. Select or record a Sound in Praat.
  2. Export as WAV to the FFmpeg folder (or use existing audio).
  3. Operation 4 (waveform) or Operation 5 (spectrogram): generate video visualization.
  4. Optionally use Operation 7 to add still image + audio for title cards.

Result: Professional video showing audio analysis for lectures, papers, or social media.

Workflow C: Video segment + Praat-selected audio → new video segment

  1. Select a Sound object in Praat (already processed).
  2. Operation 6: Set start/end times, enable Replace_audio_in_cut = yes.
  3. The script cuts the video segment and replaces its audio with the selected Praat Sound.

Result: Frame-accurate video segment with your Praat-processed audio.

Workflow C precision: Unlike operation 3 (stream copy), operation 6 re-encodes the video segment (libx264) for frame-accurate cuts. The Praat Sound's time range is exported as WAV and then merged. This guarantees exact alignment.

Parameters reference

Folder & FFmpeg

ParameterDescription
FolderPath containing ffmpeg(.exe) and input files. Use forward slashes. Example: C:/media_projects or /Users/name/ffmpeg_folder.
Dry_runIf enabled, prints FFmpeg command without executing — great for learning and debugging.默认

Operation-specific

ParameterApplies toDescription
Shortest_streamOp 1Output duration = min(video duration, audio duration)
Sample_rate / ChannelsOp 2Audio extraction quality (48000 Hz, Mono/Stereo)
Start_time / End_timeOps 3, 6HH:MM:SS.mmm or SS.mmm format
Use_duration_not_endOp 3Interpret End_time as duration instead of timestamp
Width / HeightOps 4,5,12Output video dimensions (default 1920×1080)
Frame_rateOps 4,5,12Video frames per second (default 30)
Replace_audio_in_cutOp 6Replace cut video's audio with Praat Sound (yes/no)
Hap_modeOp 10hap / hap_alpha / hap_q
Target_fpsOp 11New frame rate (e.g., 25, 30, 60)
Time format examples: 00:01:30.500 = 1 minute 30.5 seconds; 90.5 = 90.5 seconds; 00:05:00 = 5 minutes. The script validates format and exits with a clear error if malformed.

Practical examples

Example 1: Replace a video's soundtrack with a Praat-filtered audio
1. Place video.mp4 and ffmpeg.exe in folder.
2. Operation 2 (extract audio) → extract.wav opens in Praat.
3. Apply filtering/effects in Praat, then Save as WAV: processed.wav.
4. Operation 1 with input_video=video.mp4 and input_audio=processed.wav.
5. Output: video_replaced_audio.mp4 with your processed audio.
Example 2: Create a waveform video for a presentation
1. Place speech.wav and ffmpeg in folder.
2. Operation 4, set Width=1280, Height=720, Frame_rate=25.
3. Output: speech_waveform.mp4 — perfect for YouTube tutorials or lecture slides.
Example 3: Frame-accurate video segment with custom audio
1. In Praat, edit a Sound to have new audio for a 5-second region.
2. Select that Sound.
3. Operation 6: Start_time=00:00:10.000, End_time=00:00:15.000, Replace_audio_in_cut=yes.
4. Output: video_export.mp4 (frame-accurate 5-second clip with Praat audio).
Example 4: Burn subtitles for a silent film project
1. Place video.mp4, subtitles.srt, ffmpeg in folder.
2. Operation 9 (burn subtitles).
3. Output: video_hardcoded.mp4 with subtitles visible on frames.

Troubleshooting & Tips

Issue: "FFmpeg not found"
Make sure ffmpeg(.exe) is in the exact folder you typed. The script does NOT search PATH. On macOS/Linux, ensure the binary is named "ffmpeg" (no extension) and has execute permissions (chmod +x ffmpeg).
Issue: Operation 3 cut is not frame-accurate
Stream copy (-c copy) cuts at keyframes only. For frame-accurate cuts, use operation 6 (Export Praat selection as video segment) — it re-encodes the cut for precision.
Issue: Windows subtitle burning fails with "No such file"
FFmpeg's subtitles= filter parses colons as separators. The script automatically escapes drive-letters (C:/path → C\:/path). If you still see errors, check that the subtitle file is UTF-8 encoded.
Issue: Operation 6 "Start time not before end time"
Ensure the selected Sound's duration is longer than the requested end time. Use Get total duration in Praat to check.
Pro tips:
  • Always use Dry_run = yes first — the command printed in the Info window can be copied directly to a terminal for debugging.
  • Folder paths: use forward slashes on all platforms — Praat and FFmpeg accept them.
  • For high-quality waveform/spectrogram videos, increase Width to 1920 and CRF to 18 (default).
  • HAP videos (operation 10) are ideal for real-time VJ software (Max/Jitter, Resolume, TouchDesigner).
  • The script prints the full FFmpeg command before execution — great for learning FFmpeg syntax.
Changelog v1.1 improvements:
  • Fixed Windows subtitle path escaping in operation 9 (C:/ → C\:/).
  • Added folder existence pre-check — clear error instead of "no video file".
  • Added FFmpeg-not-found check with platform-specific download hints.
  • Added Dry_run toggle — preview commands without execution.
  • Refactored file detection into a single procedure (cleaner code).
  • hmsToSec now validates time format and exits with clear errors.

Under the hood: FFmpeg command construction

The script builds FFmpeg commands using Praat's string concatenation and the runSystem_nocheck command. Example for operation 4 (waveform video): ffmpeg -y -i input.wav -filter_complex "[0:a]asplit=2[awav][aout];[awav]showwaves=s=1920x1080:mode=line:rate=30[vout]" -map [vout] -map [aout] -c:v libx264 -preset fast -crf 18 -c:a aac -b:a 192k -r 30 output_waveform.mp4 All output files are written to the same folder as the input. The -y flag overwrites existing files without prompting. FFmpeg errors are printed to the Info window, and missing output files trigger a warning.
Extending the script: Advanced users can modify the cmd$ construction in each operation block to add FFmpeg filters (e.g., showwavespic for static images, ebur128 for loudness metering). The dry-run mode makes experimentation safe.
```