Repository navigation
Auto Create Directories
When ffmpeg writes a local file, any missing parent directories are created first. You do not need mkdir -p before an output.
Since: v1.0.33 for files a muxer opens itself. Since v1.0.48 for every file ffmpeg writes (#134).
Checked on v1.0.48 (linux-x86_64 and windows-x86_64). Every row writes into a directory that did not exist.
| What ffmpeg writes | Example |
|---|---|
| The main output, any format | ffmpeg -i in.mkv out/2026/movie.mp4 |
| Image sequences | -frames:v 2 img/x/f_%02d.png |
| HLS playlist and segments |
h/pl/index.m3u8 with -hls_segment_filename h/seg/s_%03d.ts
|
| Segment files and the segment list | -f segment -segment_list seg/list/l.csv seg/out/o_%03d.mkv |
Every output of tee
|
-f tee "[f=mp4]a/x/o.mp4|[f=matroska]b/y/o.mkv" |
Sprite sheet and its .vtt (spritevtt) |
sp/out.webp |
| Chapter file (chapters_vtt) | a/b/ch.vtt |
An output with a file: prefix |
file:out/o.mp4 creates out, not a directory named file:out
|
| The two-pass log | -pass 1 -passlogfile logs/pass/log |
| The two-pass stats of libx264 and libx265 | the same -passlogfile, or -x264-params stats=...
|
| Encoder debug files libx264 and libx265 write themselves |
-x264-params dump-yuv=..., -x265-params csv=... or analysis-save=...
|
| The report file | FFREPORT=file=logs/report/r.log |
The stats file of -vstats_file
|
-vstats_file logs/vstats/v.log |
| Filter stats files |
psnr=stats_file=..., ssim=stats_file=..., loudnorm=print_format=json:stats_file=..., and the other filters with a stats or log file option |
| The libvmaf log | libvmaf=log_path=logs/vmaf/v.json:log_fmt=json |
| Case | Why |
|---|---|
pipe: outputs |
Nothing is written to disk. |
Network outputs (rtmp://, http://, srt:// and others) |
Not a local file. |
| Files opened for reading | An input path never creates a directory. A missing input still fails, and no directory appears. |
| Files a library writes from a fixed name or an environment variable | ffmpeg never sees the path. Example: SVT-AV1's own debug files. |
# Both work on v1.0.48: no mkdir needed
ffmpeg -i input.mp4 -c copy out/2026/movie.mp4
ffmpeg -i input.mp4 -c:v libx264 -pass 1 -passlogfile logs/2026/pass -f null -| Rule | Detail |
|---|---|
| Write only | Created only for files opened for writing or appending. |
| Local paths only |
pipe: and network protocols are skipped. A leading file: is removed first. |
| Both separators |
/ and \ are understood on Windows; / elsewhere. |
| Windows | Drive letters (C:\) and UNC prefixes (\\server\share\) are skipped, not created. UTF-8 and long paths work. |
| Mode | New directories get mode 0755 on Unix. |
| No directory part | A bare file name in the current directory does nothing. |
| Failure | Best effort. If a directory cannot be made (permissions, or a file with that name), ffmpeg reports the real error of the open, for example Not a directory. |
The patch is in every platform build. On Unix it uses mkdir; on Windows it uses _wmkdir on the UTF-8 path.
The tests write a file into a new directory for every row above and check the file exists: tests/lib/autodir.sh and tests/lib/autodir.ps1, 25 checks, run in the smoke test of every release.
Before v1.0.48: only image sequences and HLS got their directories. The main output of ffmpeg -i in out/new/o.mp4 failed with No such file or directory.
Users
Filters and components
- Filter-stemsplit
- Filter-lyricsalign
- Whisper-Language-Detection
- Whisper-Word-Timestamps
- Filter-trailingsilence
- Filter-keydetect
- Filter-beatdetect
- Filter-rubberband
- Muxer-Sprite-Sheet
- Muxer-Chapter-VTT
- Muxer-VOBsub
- Protocol-dvdread
- Protocol-OmniDrive
- Auto-Create-Directories
- AACS-and-BDplus
- HLS-Master-Playlist
- Subtitles-OCR
- HEVC-Alpha
Acceleration and codecs
Contributors