nodejs为命令参数添加双引号?

时间:2020-12-15 05:41:43

Example:

ffmpeg -i test.mkv -metadata title="Test 123" -c copy temp.mkv

ffmpeg sees ""Test 123"". It happens with spawn() and execFile()

ffmpeg看到“”测试123“”。它发生在spawn()和execFile()

If I run the same command in the windows shell ffmpeg sees it correctly as "Test 123"

如果我在windows shell中运行相同的命令,ffmpeg会将其正确地视为“Test 123”

So what's up with nodejs?

那么nodejs有什么用呢?

Here's the nodejs code:

这是nodejs代码:

var process = spawn('ffmpeg', [
  '-i',
  inFile,
  '-metadata',
  'title="Test 123"',     
  '-c',
  'copy',
  outFile
]);

1 个解决方案

#1


2  

You just need to switch to "title='Test 123'" since double quotes have precedence over single quotes. Your stdin should then just parse it right to title="Test 123".

您只需切换到“title ='Test 123'”,因为双引号优先于单引号。然后你的标准输入应该直接解析为title =“Test 123”。

#1


2  

You just need to switch to "title='Test 123'" since double quotes have precedence over single quotes. Your stdin should then just parse it right to title="Test 123".

您只需切换到“title ='Test 123'”,因为双引号优先于单引号。然后你的标准输入应该直接解析为title =“Test 123”。