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.
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.
Supported operations (12 total):
ffmpeg (macOS/Linux) or ffmpeg.exe (Windows) in the same folder as your input files.
- macOS: https://evermeet.cx/ffmpeg/ or
brew install ffmpeg - Windows: https://www.gyan.dev/ffmpeg/builds/
- Linux:
apt install ffmpegordnf install ffmpeg
Quick start
- Create a folder with ffmpeg (or ffmpeg.exe) and your input media files (video, audio, image, subtitle).
- In Praat, run
Media_ffmpeg_tools.praat. - Enter the folder path (use forward slashes:
C:/ffmpeg_folderor/Users/name/videos). - Select an operation (1–12).
- Adjust operation-specific parameters (cut times, dimensions, frame rate, etc.).
- Enable Dry_run to preview the FFmpeg command without executing.
- Click OK — FFmpeg runs, output appears in the same folder, and operation 2/6 load results into Praat automatically.
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
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
Parameters: Sample_rate (48000 default), Channels (Mono/Stereo).
Operation 3: Cut video without re-encoding (stream copy)
-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
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
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
Parameters: Start_time, End_time, Replace_audio_in_cut (yes/no).
Operation 7: Still image + audio → video
audio_image_video.mp4.
Operation 8: Add soft subtitles (mov_text, MP4)
video_subtitled.mp4.
Supported subtitle formats: .srt, .ass, .ssa.
Operation 9: Burn subtitles into video (hardcode)
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)
video_hap.mov.
Hap_mode: hap (standard), hap_alpha (with alpha channel), hap_q (quality variant).
Operation 11: Change video frame rate
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
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
- Operation 2: Extract audio from video → opens in Praat.
- Process the audio in Praat (filter, transform, analyze, etc.).
- Save the processed audio as WAV (or keep in memory).
- 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
- Select or record a Sound in Praat.
- Export as WAV to the FFmpeg folder (or use existing audio).
- Operation 4 (waveform) or Operation 5 (spectrogram): generate video visualization.
- 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
- Select a Sound object in Praat (already processed).
- Operation 6: Set start/end times, enable Replace_audio_in_cut = yes.
- 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.
Parameters reference
Folder & FFmpeg
| Parameter | Description |
|---|---|
| Folder | Path containing ffmpeg(.exe) and input files. Use forward slashes. Example: C:/media_projects or /Users/name/ffmpeg_folder. |
| Dry_run | If enabled, prints FFmpeg command without executing — great for learning and debugging.默认 |
Operation-specific
| Parameter | Applies to | Description |
|---|---|---|
| Shortest_stream | Op 1 | Output duration = min(video duration, audio duration) |
| Sample_rate / Channels | Op 2 | Audio extraction quality (48000 Hz, Mono/Stereo) |
| Start_time / End_time | Ops 3, 6 | HH:MM:SS.mmm or SS.mmm format |
| Use_duration_not_end | Op 3 | Interpret End_time as duration instead of timestamp |
| Width / Height | Ops 4,5,12 | Output video dimensions (default 1920×1080) |
| Frame_rate | Ops 4,5,12 | Video frames per second (default 30) |
| Replace_audio_in_cut | Op 6 | Replace cut video's audio with Praat Sound (yes/no) |
| Hap_mode | Op 10 | hap / hap_alpha / hap_q |
| Target_fps | Op 11 | New frame rate (e.g., 25, 30, 60) |
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
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.
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.
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).
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
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).
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.
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.
Ensure the selected Sound's duration is longer than the requested end time. Use
Get total duration in Praat to check.
- 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.
- 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
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.
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.