VLC command line - output path quoting problem

Microsoft Windows specific usage questions
Forum rules
Please post only Windows specific questions in this forum category. If you don't know where to post, please read the different forums' rules. Thanks.
zithro
New Cone
New Cone
Posts: 3
Joined: 07 Jan 2016 23:40

VLC command line - output path quoting problem

Postby zithro » 11 Nov 2016 20:26

Hello,

I use command line VLC to extract audio from videos and I have a little problem with quoting the destination filename/path.

The following command (built within batch files or directly in cmd) works well most of the times:

Code: Select all

cmd> "C:\Program Files\VideoLAN\VLC\vlc" -vvv -I dummy "M:\--- Path ---\file with spaces.mp4" --no-sout-video --sout-avcodec-strict=-2 --sout=#std{access=file,mux=mp4,dst="M:\--- Path ---\file with spaces.m4a"}
The OUTPUT path "--- Path ---" is correctly handled, the spaces in the file too.

But when run with a path like "--- Path, with Comma ---", like this :

Code: Select all

cmd> "C:\Program Files\VideoLAN\VLC\vlc" -vvv -I dummy "M:\--- Path, with Comma ---\file with spaces.mp4" --no-sout-video --sout-avcodec-strict=-2 --sout=#std{access=file,mux=mp4,dst="M:\--- Path, with Comma ---\file with spaces.m4a"}
The OUTPUT file is correctly created, meaning the INPUT file is correctly read/quoted, but the path of the OUTPUT file gets truncated at the comma located in the path : the filepath is then "M:\--- Path", The file being "--- Path" (a file without extention)

As per "https://wiki.videolan.org/Transcode" in the Windows section, I tried doubling the backslashes, to no avail.
While double-backslashing paths, I tried sinple-backslashing the comma, but it got interpreted as a path separator too.
It's not really clear if there is a "VLC" escape character, but it seems a comma is interpreted even in double quotes inside the curly braces.
[ Side notes about the Transcode wiki page:
- on Windows 7 x64 and VLC 2.2.4, using "--sout=#standard{..." or "--sout=#std{..." is the same. The doc is a bit obscure on that.
- I cant find anymore the "SendTo" scripts, were they removed ? I used them as a base for my current SendTo scripts. ]

Am I missing something or is it a VLC bug ?

Thanks !

PS: I know I could extract first to a "correct/without commas" temporary path, then copy the file, but ... ;)

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: VLC command line - output path quoting problem

Postby mederi » 12 Nov 2016 15:08

It should work if you use double quotes (") together with single quotes ('): "'M:\--- Path, with Comma ---\file with spaces.m4a'".
But what if there is a single quote (apostrophe) somewhere in the path ("'Daddy's Folder'")?

Code: Select all

vlc.exe "%~1" --sout=#std{access=file,mux=mp4,dst="'%~1.m4a'"}

zithro
New Cone
New Cone
Posts: 3
Joined: 07 Jan 2016 23:40

Re: VLC command line - output path quoting problem

Postby zithro » 13 Nov 2016 01:12

I tried your suggestion with simple quotes, and it's effectively working with commas, thanks.
But as you pointed out, if there's (also) a simple quote in the title, it's the same problem all over again.
It seems there's no safe way to do it, I guess the command line parser is not ignoring special characters inside quotes/double quotes for the "dst=" option only (as the input file quoting works).

Is that a known bug or limitation ?
By the way, your trick with single quotes, did you read that somewhere in the doc/forum, or you know it "by trying" ?

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: VLC command line - output path quoting problem

Postby mederi » 13 Nov 2016 14:42

Probably it is a shared experience in some old topic on this forum. You could try to search the VLC bug tracker and if there is not a related ticket yet, then please file a new bug report: https://trac.videolan.org/vlc

zithro
New Cone
New Cone
Posts: 3
Joined: 07 Jan 2016 23:40

Re: VLC command line - output path quoting problem

Postby zithro » 15 Nov 2016 20:37

Found some related tickets, but for other interfaces, all fixed and closed.
Ticket "convert save single quote in filename bug" (6696), duplicate of "Convert does not work when the file name contains a ' [quote]" (6547), is for the Qt interface, in some convert parts, but seems related to my problem.
Ticket "Media convert dialog doesn't allow valid filename characters" (8436) is also for Qt, but shows an interesting bugfix in the comments: "Qt: ConvertDialog?: Escape filename in sout".

So it seems all GUI wrappers have been correctly updated concerning the simple quote problem, and are quoting properly any input/output. But that does not solve the comma problem in command line.
Should I open a bug report for this specific case, or just ask the devs for some clarification about the correct quoting one should adopt ?

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: VLC command line - output path quoting problem

Postby mederi » 15 Nov 2016 22:11

Thank you for searching the VLC bug tracker. I was lucky and found it there: #1906 Perhaps you could refresh the ticket by adding your brief comment there describing your own experience. The workaround works, but single quote character is still an issue.

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: VLC command line - output path quoting problem

Postby mederi » 16 Nov 2016 22:26

It seems that escaping the ' character in a batch file is no big deal at all:

Code: Select all

set output=%~1.m4a set escaped_output=%output:'=\'% vlc.exe "%~1" --sout=#std{access=file,mux=mp4,dst="'%escaped_output%'"} vlc://quit


Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: No registered users and 40 guests