| Tested on | RHEL 10.2 (Coughlan) — vm1.lab.example |
|---|---|
| Package | ffmpeg-free 7.1.2-1.el10_2 |
| Applies to | Ubuntu, Debian, Kali Linux, Linux Mint, Pop!_OS, Raspberry Pi OS, elementary OS, Zorin OS, Parrot OS, MX Linux, RHEL, Rocky Linux, AlmaLinux, Oracle Linux, CentOS Stream, Fedora, Arch Linux |
| Privilege | Normal user for files you own; write access to the output directory |
| Scope | Set FFmpeg input and output paths on the command line and in short bash scripts. Does not cover FFmpeg filters, streaming, or batch conversion loops. |
| Related guides | Install FFmpeg on Rocky Linux 9 Install ffprobe on Ubuntu bash command Linux commands |
FFmpeg has no separate output-directory switch. The folder is part of the output filename path you pass on the command line — not a standalone flag you set elsewhere.
-i marks the input file; the output argument names the destination file, including which directory it should land in. This guide uses the common one-input, one-output form: ffmpeg -i input output.
Add -y only when you want FFmpeg to overwrite an existing output file without prompting. Use -n if it should refuse to overwrite instead.
Set the FFmpeg output directory
Use a full path on both sides when input and output live in different folders:
ffmpeg -i /home/user/Videos/input.mp4 /home/user/converted/output.mp4-i /home/user/Videos/input.mp4— where FFmpeg reads from./home/user/converted/output.mp4— where FFmpeg writes to. The directory is part of that path.
/home/user/converted/ is the output directory because it is included in the output path. FFmpeg creates output.mp4 there. The converted directory must already exist — FFmpeg creates the file, not missing parent folders.
Create the destination folder first when needed:
mkdir -p /home/user/convertedA relative output path works the same way if you prefer shorter commands from your project tree:
ffmpeg -i /data/archive/clip.m4a ./exports/clip.mp3Here ./exports/clip.mp3 writes into the exports directory under your current working directory.
Confirm the file landed where you expected:
ls -lh /home/user/converted/output.mp4Save output in the current directory
When the output name has no directory component, FFmpeg writes into your current working directory — not automatically into the input file's folder.
Check where your shell is:
pwdSample output:
/home/user/VideosFrom that directory, a bare output filename stays local:
ffmpeg -i /data/input/sample.m4a output.mp3Because output.mp3 has no path prefix, FFmpeg creates it in /home/user/Videos (whatever pwd showed). It does not place the file next to /data/input/sample.m4a unless you cd there or pass a full output path.
Verify with:
ls -lh output.mp3Use relative input and output paths
When your shell is already in the project root, relative paths keep both sides short:
ffmpeg -i ./input/file.wav ./output/file.mp3./input/file.wav— read from theinputfolder under the current directory../output/file.mp3— write into theoutputfolder under the current directory.
The input file must already exist, and the output directory must already exist.
Set input and output directories in Bash
For repeated jobs, store directories in variables and quote the full paths:
input_dir="/data/input"
output_dir="/data/output"
ffmpeg -i "$input_dir/sample.m4a" "$output_dir/sample.mp3"Double quotes protect paths that contain spaces. The filename still has to be part of the output path — output_dir by itself is not enough. That is the same rule as on the command line: the directory is included in the full output path, not passed as a separate FFmpeg option.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Output file not next to the input | Bare output filename uses current directory, not input directory | cd to the target folder or use a full output path |
No such file or directory on output |
Parent folder missing | mkdir -p /path/to/output before running FFmpeg |
Permission denied |
No write access to output directory | Fix ownership or choose a directory your user can write |
| Existing file was overwritten | Command used -y |
Remove -y to get a prompt, or use -n to refuse overwriting |
| Wrong input converted | Wrong path after -i |
Check the input path before running FFmpeg |
References
Summary
There is no FFmpeg output-directory option. Put the folder in the output path: -i points at the source file, and the output argument names the destination file including its directory. A bare filename such as out.mp3 lands in your current working directory; /var/media/out/out.mp3 lands in /var/media/out/.
Create the parent directory before you run FFmpeg, use quoted input_dir and output_dir variables in scripts for repeat jobs, and check the result with ls -lh on the path you passed.

