video_transcoding: Can't (directly) copy commands from detect-crop on Windows
First, a big “thank you” for the time and effort you’ve put into these scripts – they’ve been producing great results for me ever since I found them.
One minor annoyance I’ve come across, though, is that when I’m using Windows to detect crop values, I can’t directly copy and paste the preview commands out of the detect-crop output.
detect-crop produces commands that look like this:
mpv --no-audio --vf 'lavfi=[drawbox=10:0:704:576:invert:1]' Some\ File\ With\ Spaces.mkv
but cmd.exe doesn’t support either single quotes or backslash escaping for filenames. Would it be possible, at least on Windows, to produce commands like this instead:
mpv --no-audio --vf "lavfi=[drawbox=10:0:704:576:invert:1]" "Some File With Spaces.mkv"
? It would save me a bunch of time, especially when I have a big batch of files to process, to not have to manually edit each command.
Thanks again!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 49 (47 by maintainers)
Commits related to this issue
- Modify `detect-crop` to escape preview commands for Z shells. — committed to lisamelton/video_transcoding by lisamelton 7 years ago
@samhutchins and @forty2 OK, here’s my reworded text:
I’m going with that unless I hear otherwise. 😃
I don’t like recommending that people use Cygwin, because it’s completely unnecessary for this application and it’s such a pain to uninstall. But hey, if people already have it and they wanna use it I have no problem with that 😛
I feel that you’re the master of wording Don, but I think @forty2 had a pretty good suggestion
Hi all,
Sorry for not chiming in sooner; I was traveling and away from my computer.
Thanks for jumping in so quickly and taking this so seriously! For my purposes, the workaround of just using bash while working on a big batch of videos is good enough, but thanks for fixing the zsh regression (it did seem like this got more annoying recently, but I couldn’t put my finger on why…)
The only other thing I would add is you might consider explicitly suggesting
bash.exeas an alternative in the README comment – trying bash never occurred to me until you suggested trying PowerShell, so it may not occur to other people either. Maybe something like:Whatever you think is best; in any case, this bug is sufficiently fixed to solve my problem. Thanks again!
@donmelton looks good 👍
@donmelton It does indeed return
truein Git Bash on Windows. I’d guess the same is true in Cygwin, but I don’t fancy installing it to find out I’m afraid.@samhutchins BTW, I’ll tackle this and merge that dandy patch of yours, #147, when I get back to my development machine tomorrow.
Yay for different rules on different systems. On Windows you can’t put a double quote, question mark, or colon in the filename, it won’t let you.
https://support.microsoft.com/en-us/help/905231/information-about-the-characters-that-you-cannot-use-in-site-names,-folder-names,-and-file-names-in-sharepoint
At this point I’d be inclined to re-fix the issues on zsh in a way that doesn’t cause problems on Windows, then accept and document the poor filename escaping on Windows.
In terms of fixing the escaping on Windows, I think the best we can do is simply detect that the program is running on Windows and use some different escaping rules, I just don’t think there’s a way to detect if the program was launched via CMD or PowerShell.
Also maybe worth a quick read: http://stackoverflow.com/questions/30620876/how-to-properly-escape-filenames-in-windows-cmd-exe
I tried a couple of promising looking things, but there’s nothing concrete in there. I’ll keep trying things, see how it goes
I’ve done a little bit of digging, and made a local change to demonstrate the idea:
The result of this change:
This makes the command directly copy-able on Windows, but effectively reverts 96c490511c5f2fef445791c405acbe3c4333058c in the process. I dunno how to deal with Z shells without breaking Windows. Not to say it can’t be done, just that I’ve never used (or really heard of) Z shells
I also don’t know the effects of just wrapping the arg in
"instead ofshellescapeis on Unix-like systems. I can’t easily test today, the only Mac I have access to is in the office