Skip to content
streamneo.
Troubleshooting11 min read

How to Make FFmpeg Read Video Filenames with Spaces in a YouTube Playlist

Fix spaces in FFmpeg filenames by quoting direct inputs and concat-list paths separately, then use -safe 0 only with a trusted list.

sn.
StreamNeoPublished 7 October 2026
Worth sharing?

If FFmpeg cannot read a video filename containing spaces, first check where that filename is being parsed. Quote a direct input path for your shell; for a concat-demuxer playlist, quote or escape each path inside the list file as well.

These are separate fixes. A shell can pass a correctly quoted list filename to FFmpeg while FFmpeg still rejects a badly written entry inside that list, or flags its path as unsafe. The right fix depends on the input format and the exact error.

Identify how FFmpeg receives the filename

“Playlist” can mean several things: a local text file used by FFmpeg’s concat demuxer, a set of files named in a script, or a YouTube playlist URL. The first step is to identify what you actually pass to FFmpeg. A local concat list is not parsed in the same way as a filename supplied directly with -i.

For a direct input, the shell reads your command first. It interprets spaces as separators unless quoting keeps the entire path together. FFmpeg then receives the path as one argument. For example, the intended input might be a single file named Evening Bhajan.mp4, not two arguments named Evening and Bhajan.mp4.

A concat list adds another parsing layer. The shell passes the name of the text file, such as files.txt, to FFmpeg. Then the concat demuxer reads each file line and parses its path according to concat-list syntax. Quoting files.txt in the shell does not quote the paths written inside it.

A downloader introduces a different step: it chooses local output names. A tool such as yt-dlp may save a title with spaces, which is ordinary filename behaviour. Its documentation describes --restrict-filenames for workflows where you prefer to avoid spaces and some other special characters. That can make a naming convention simpler, but it does not replace understanding how FFmpeg parses paths. See the yt-dlp project documentation.

If the input is a YouTube URL or playlist URL, do not assume FFmpeg treats it as a local playlist of downloaded videos. URL handling is a separate workflow, often involving a downloader before FFmpeg receives local files. This article focuses on local paths and concat lists; first confirm that your command is operating on downloaded files.

Quote a direct input path in the shell

When you supply one video directly, quote the whole path as one shell argument. In a POSIX-style shell such as Bash, this is a common form:

ffmpeg -i "Evening Bhajan.mp4" -c copy output.mp4

Single quotes also work in Bash when the path itself contains no single quote:

ffmpeg -i 'Evening Bhajan.mp4' -c copy output.mp4

If the file is in a directory whose name also contains spaces, quote the full path:

ffmpeg -i "/home/channel owner/videos/Evening Bhajan.mp4" -c copy output.mp4

The quotes are syntax for the shell; they are not normally part of the filename passed to FFmpeg. Do not copy Bash quoting blindly into PowerShell or Windows Command Prompt. Their command-line parsing rules differ, and quoting embedded in a script may add another escaping layer. The FFmpeg documentation on quoting and escaping calls out that a second level of escaping may be needed when a command or script embeds FFmpeg syntax.

A useful diagnostic clue is a reported path that stops at the first space, or a message saying that a truncated name cannot be opened. That suggests the direct argument was split before FFmpeg received it. Check how your shell expects a path to be quoted, then ensure the argument after -i is a single path. If you invoke FFmpeg through a batch file, a programming language, or a graphical command runner, account for that layer too.

Do not add concat-list escaping to a direct -i path. The two cases have different parsers. For one local file, shell quoting is the relevant step; for a concat list, the entries within the list need their own syntax.

Quote paths inside a concat list

The concat demuxer reads a text file in which each input is introduced by file. A minimal list for two files in the list file’s directory can be written as:

ffconcat version 1.0
file 'video one.mp4'
file 'video two.mp4'

The quote marks here belong to the concat-list syntax. They group each path for the concat demuxer; they are not shell quotes, because the shell does not read the contents of files.txt. FFmpeg’s concat demuxer documentation says spaces and special characters in a path must be escaped with a backslash or enclosed in single quotes.

You can also escape spaces with backslashes in the list, for example:

ffconcat version 1.0
file video\ one.mp4
file video\ two.mp4

Choose one representation and keep it consistent. Quoting the path is often easier to inspect, while escaping may suit a script that generates the list. If a filename itself includes a single quote, a backslash, or other punctuation, the concat syntax requires careful escaping; do not assume that the shell’s quoting recipe applies to that text. Check the concat demuxer rules and test a small list before building a long one.

Then pass the list file to FFmpeg. If its own path contains spaces, quote that argument for your shell too:

ffmpeg -f concat -i "playlist files.txt" -c copy combined.mp4

There are now two independent path decisions: the shell must pass playlist files.txt as one argument, and the concat demuxer must parse each entry in that file. If FFmpeg opens the list but cannot open video one.mp4, editing the shell quotes around playlist files.txt is unlikely to fix an entry that is malformed inside the list.

For a repeatable playlist, keep the list as plain text and inspect its actual contents. A generated file can contain unexpected quotation marks, line breaks, or directory prefixes. If the error output names an entry differently from what you intended, compare that exact path with the line in the list before changing other parts of the command.

Use -safe 0 only for a trusted list

Even correctly quoted paths with spaces can meet a second obstacle: the concat demuxer’s default safety check. Its safe mode permits only a restricted set of portable path characters; spaces are outside that set. If the error specifically identifies an unsafe filename or path, safety validation may be the issue rather than shell parsing.

For a concat list you created and have inspected, you can allow paths outside that restricted set with -safe 0:

ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4

The position matters: -safe 0 is an input option for the concat demuxer, so place it with the concat input options before -i files.txt. The example shows the command pattern, not a tested command for every shell or media pair. If files.txt itself has a space in its name, quote that name according to your shell as in the previous section.

This setting relaxes path validation; it does not repair malformed quoting, missing files, or incompatible media. It also changes what paths the demuxer will accept. Use it only when the list is trusted: for example, one you wrote yourself or generated from inputs you control and then reviewed. Do not use it as a blanket setting for an untrusted list received from someone else or downloaded from an unknown source.

If you are unsure whether the safety check is the problem, distinguish the error messages. A path reported as unsafe points towards concat safety validation. A missing-file error showing a name cut off at a space points towards quoting or list syntax. Fix the indicated layer first rather than adding options at random.

Run a minimal concat test

Before relying on a long playlist, test the same syntax with a short list containing two files that you can locate. Keep the list and the sample videos in a simple directory, write the list by hand, and use filenames with spaces. This isolates list parsing from downloader templates, scheduled jobs, and streaming software.

Start with the ffconcat version 1.0 header and two file entries in single quotes. Run the command without -safe 0 first. If FFmpeg reports an unsafe path because the entries contain spaces, and you control the list, repeat the test with -safe 0. If it instead reports that a file cannot be opened, verify the path spelling and where the demuxer expects to find the file.

A successful read is not the same as a successful stream-copy concatenation. The concat demuxer joins packet streams, so the input files need matching streams, codecs, and time bases for this approach to work properly. Two files that differ can fail or produce undesirable output even when every filename is parsed correctly. The FFmpeg concat documentation covers this compatibility requirement as well as the demuxer syntax.

If you suspect a media mismatch, inspect the inputs before treating a failed stream-copy command as a path problem. Where files do not have compatible streams, a workflow that decodes and re-encodes them, such as use of the concat filter, may be more suitable. That involves different command syntax and a quality or processing trade-off; do not switch methods without checking the actual files and your output requirements.

A small test is also a way to establish which syntax your shell accepts. Keep the example command and list file separate, and change one thing at a time: list-entry quoting, safe-path handling, then media compatibility. If several factors change together, a success or failure tells you less about the original fault.

Check relative paths and the working directory

A path such as file 'video one.mp4' is relative, not universal. It is interpreted in relation to the concat demuxer’s path handling and the location from which the list is read; in many practical cases, keeping the videos beside the list makes the first test straightforward. When your files live elsewhere, use an explicit path and verify it carefully rather than assuming the command starts in the directory you expect.

The working directory can change when FFmpeg is launched from a scheduled task, a service manager, a script, or a streaming application. A command that works in an interactive terminal may fail overnight because the process starts in another directory. The list itself may also be referenced with a relative path, creating a second location to check.

For a reliable test, note the directory where you run FFmpeg and the directory containing files.txt. Confirm that each relative entry resolves to an existing file from the intended context. If you choose absolute paths, quote or escape them in the list according to concat syntax, and use -safe 0 only if the trusted paths require it. An absolute path still needs correct list syntax.

Keep filenames and list paths stable once the test works. Renaming a video, moving the list, or changing a scheduled process’s working directory can break a previously valid playlist without changing the FFmpeg command. When troubleshooting, inspect the actual path on disk and the exact path written in the list, not just the display title shown by a media library.

Verify the playlist in the stream workflow

Once the local concat test passes, integrate it into the process that prepares or broadcasts your YouTube loop. If yt-dlp creates the files, check the downloaded names and the location used by the later FFmpeg step. You can either preserve spaces and write valid concat entries, or choose a restricted naming scheme to avoid them; those are workflow preferences, not evidence that FFmpeg cannot handle ordinary names.

Run the exact command from the same account, script, or application that will operate the stream. Confirm that it can read the list, open every source file, and produce the intended output before relying on it for a long-running broadcast. A manual test under your desktop account does not establish that a scheduled process has access to the same files or starts in the same directory.

Keep a copy of the list and the command that worked. If you later add videos, verify each new entry rather than assuming that one correctly quoted filename validates the whole playlist. Also check that the added video’s streams are compatible with the existing files if you are using packet-level concatenation.

For a wider operational check, consider how playlist timing and restart behaviour fit the rest of the broadcast. The guide to setting different playlist start times for multiple FFmpeg YouTube streams is relevant when you run more than one loop, while the article on restarting a YouTube stream after FFmpeg exits addresses recovery after a process stops. Neither replaces verifying the file paths before starting the stream.

If keeping a local computer running to maintain a file-based loop is the part that keeps failing overnight, StreamNeo removes that particular burden: you upload the video once, provide your YouTube stream key, and the broadcast continues without your computer running. It does not change the need to prepare and check the video file, and it is for YouTube rather than other platforms. If you stay with a local FFmpeg workflow, the guide to keeping a devotional stream running during an ISP outage may help you think through a separate source of interruption.

Before committing, compare the operating options on the pricing page. When the file and channel are ready, start free — 24-hour trial, no card.

FAQ

Does quoting files.txt fix spaces in its video filenames?

No. Quoting the list filename makes the shell pass that one path to FFmpeg as a single argument. You must separately quote or escape each video path inside the concat list according to concat-demuxer syntax.

Why does a correctly quoted list still produce an unsafe-path error?

The concat demuxer applies its own safety check, which rejects some path characters, including spaces, by default. For a list you control and have checked, -safe 0 can relax that validation; it is not a safe default for an untrusted list.

Should I remove spaces from downloaded filenames?

You can choose a downloader naming option such as yt-dlp’s --restrict-filenames if that suits your workflow. It is a convenience, not a requirement for FFmpeg: you still need shell quoting for direct inputs and valid concat syntax for paths inside a list.

Does a readable playlist guarantee that -c copy will concatenate the videos?

No. Correct path handling makes files addressable, but the concat demuxer also requires compatible streams, codecs, and time bases for packet-level concatenation. Check the media properties; if the files differ, another workflow such as re-encoding may be needed.

YOU’VE REACHED THE END

Keep the ideas coming.

More guides, useful tools and a little help for your next broadcast.

Back to the journal ↗
YOUR NEXT READ

A little more to explore.

More Troubleshooting guides ↗ · All topics ↗