How to Set the FFmpeg Output Directory on Linux

Deepak Prasad
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:

bash
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:

bash
mkdir -p /home/user/converted

A relative output path works the same way if you prefer shorter commands from your project tree:

bash
ffmpeg -i /data/archive/clip.m4a ./exports/clip.mp3

Here ./exports/clip.mp3 writes into the exports directory under your current working directory.

Confirm the file landed where you expected:

bash
ls -lh /home/user/converted/output.mp4

Save 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:

bash
pwd

Sample output:

output
/home/user/Videos

From that directory, a bare output filename stays local:

bash
ffmpeg -i /data/input/sample.m4a output.mp3

Because 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:

bash
ls -lh output.mp3

Use relative input and output paths

When your shell is already in the project root, relative paths keep both sides short:

bash
ffmpeg -i ./input/file.wav ./output/file.mp3
  • ./input/file.wav — read from the input folder under the current directory.
  • ./output/file.mp3 — write into the output folder 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:

bash
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.


Frequently Asked Questions

1. Does FFmpeg have an output directory option?

No. The output path you pass on the command line includes the directory. For example ffmpeg -i input.mp4 output/output.mp4 writes to the output folder because that path is part of the output filename.

2. Why did my output file land in the wrong folder?

A bare filename such as out.mp3 is created in your current working directory, not next to the input file. cd to the target folder first, or pass a full output path.

3. Can I set input and output directories in a bash script?

Yes. Store paths in variables such as input_dir and output_dir, then run ffmpeg -i "$input_dir/file.m4a" "$output_dir/file.mp3".

4. How do I see where FFmpeg wrote the file?

List the path you passed on the command line, for example ls -lh /home/user/converted/output.mp4. FFmpeg stderr also prints Output #0 with the destination path.
Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware.

  • Debian
  • Ubuntu
  • Linux
  • Red Hat Enterprise Linux
  • Shell Script
  • System Administration