Skip to content

Start typing. Errors match on their exact yt-dlp output.

to move, to open esc to close

Fix "Postprocessing: ffmpeg exited with code 1" in yt-dlp

Tested on yt-dlp 2026.07.28 Updated
What yt-dlp prints
ERROR: Postprocessing: Error opening output file Some Video.mp4.
Error opening output files: Invalid argument
ffmpeg exited with code 1

Quick answer

The download finished. The conversion afterwards failed — so no yt-dlp flag about formats or quality will help. The error is ffmpeg's, and the four things that cause it are a codec that does not fit the container, a filename the filesystem refuses, no disk space, or a locked file. Start by keeping the source files so a retry costs nothing:

bash
yt-dlp --keep-video --restrict-filenames "URL"

Reading the real error

ffmpeg exited with code 1 is not the error. It is yt-dlp reporting that ffmpeg failed; the reason is in the lines above it, and yt-dlp usually truncates them. Get the whole thing:

bash
yt-dlp -v --keep-video "URL"

What to look for in the output:

ffmpeg saysIt means
Invalid argumentFilename or path — illegal character, or too long
could not find tag for codecThe codec does not fit the container
No space left on deviceDisk full — merging needs room for a second copy
Permission deniedAntivirus or another program holding the file
Invalid data foundThe download is corrupt; delete the .part files

Cause 1 — codec and container do not fit

mp4 is a fussy container. It will not hold Opus audio, and it will not hold VP9 video in a way most players accept. YouTube serves both routinely, so --merge-output-format mp4 fails on exactly the videos where those codecs turn up.

Two ways out. Ask for codecs mp4 can hold:

bash
yt-dlp -f "bv*[vcodec^=avc1]+ba[acodec^=mp4a]/b[ext=mp4]/b" --merge-output-format mp4 "URL"

Or stop insisting on mp4. mkv holds anything, and every current player reads it:

bash
yt-dlp --merge-output-format mkv "URL"

Cause 2 — the filename

Video titles contain colons, quotes, emoji and slashes. Windows refuses several of those outright, and every filesystem has a path length limit that a long title inside a deep folder will find:

bash
yt-dlp --restrict-filenames --trim-filenames 120 "URL"

--restrict-filenames reduces names to ASCII with no spaces. Worth having on permanently if files ever land on a network share or an external drive — output templates covers naming properly.

Cause 3 — disk space

Merging is not free. ffmpeg writes a new file while the two source streams still exist, so the peak requirement is roughly twice the finished size. A drive with 2 GB free will fail to merge a 1.5 GB video, and the error says Invalid argument rather than anything about space.

Put temporary files somewhere with room:

bash
yt-dlp -P "temp:/var/tmp" -P "home:/media/archive" "URL"

Cause 4 — something is holding the file

On Windows, real-time antivirus scans each completed download, and ffmpeg cannot open a file being scanned. The symptom is intermittent, which is what makes it hard to place. Retrying is the fix:

bash
yt-dlp --file-access-retries 5 "URL"

A cloud-sync folder — OneDrive, Dropbox, Google Drive — causes the same thing for the same reason. Download somewhere local and move the file afterwards.

Retrying without downloading again

If --keep-video was on, the two source files are still there and ffmpeg can be run directly. -c copy means "do not re-encode", so this takes seconds:

bash
ffmpeg -i "video.f137.mp4" -i "audio.f140.m4a" -c copy "output.mp4"

If it still fails

  • Only when extracting audio. A missing encoder rather than a broken file. On Debian and Ubuntu, sudo apt install libavcodec-extra. See the audio guide.
  • Only with --embed-subs. mp4 accepts a narrow set of subtitle formats. Add --convert-subs srt, or switch the container to mkv.
  • Only with --embed-thumbnail. WebP thumbnails do not embed into mp4. --convert-thumbnails jpg fixes it.
  • Every video, every option. Suspect the ffmpeg build. A minimal or stripped-down build lacks encoders yt-dlp assumes are present — the yt-dlp project's own builds are the ones to test against.

Frequently asked

Do I have to download the video again?
No. --keep-video keeps the source files after postprocessing, and if they are still in the folder you can retry the conversion with ffmpeg directly. Without that flag yt-dlp deletes them once postprocessing reports success, which is exactly what did not happen here.
Why does the same command work on another video?
Because the failure usually depends on the specific streams. An Opus audio track cannot go into an mp4 container; a VP9 video cannot either. Which codecs a video is served in varies by upload, so the same command hits the incompatibility on one video and not the next.
What does "Invalid argument" mean here?
Almost always a filename problem rather than an ffmpeg problem — a character the filesystem refuses, or a path over the length limit. --restrict-filenames removes both causes at once.
Should I use --recode-video to force a format?
Rarely. It re-encodes the whole file, which is slow and lossy. --remux-video changes the container without touching the streams and solves most container mismatches instantly.