20

I want to concatenate files with ffmpeg using Concat demuxer as described in this article How to concatenate (join, merge) media files. My files, however contain, single quotes (apostrophes). So my concat.list looks like this:

file 'artist's song.mp3'
file 'artist's song 2 .mp3'

As you can see the apostrophe in the middle of the filename conflicts with the format of the concat file. Putting backslash doesn't help, because ffmpeg reads the filename literary and complains that the file doesn't exist. As additional detail, I'm using ffmpeg with cygwin under Windows 7.

2 Answers 2

25

You need to put everything in single quotes, and escape every single quote with

'\''

So,

foo'bar test.mp4

would be specified as:

file 'foo'\''bar test.mp4'

You can imagine it as the string being split where the first pair of single quotes end, and then continued later:

'foo'   \'   'bar test.mp4'

This is also explained in the documentation:

The quote character ' itself cannot be quoted, so you may need to close the quote and escape it.

and this bug report.

0

FYI for programmers:

Just escape ' and \ and do not attempt to wrap the output in single quotes.

public String escapePath(File file)
{
  String f = file.getAbsolutePath();
  f = f.replace("\\","\\\\").replace("'","\\'");
  assert(f.trim().equals(f)); // unlikely, but handle if you want
  return f;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .