dzm
dzm

Reputation: 23534

Node.js spawn not working with quotes inside argument

I'm trying to run this command with spawn

var args = ['-ss','00:00:15','-i',storage_path + doc.file_name,'-vframes','1','-vf','"scale='+size*2+':ih*'+size*2+'/iw,crop='+size+':'+size+'"','-f','image2','-q:v','5',storage_path + output_name];

var command = spawn('ffmpeg', args);

The issue seems to be with this part here: '"scale='+size*2+':ih*'+size*2+'/iw,crop='+size+':'+size+'"'

When I log the args, this is what I get:

[ '-ss', '00:00:15', '-i', '/a/video.mp4', '-vframes', '1', '-vf', '"scale=150:ih*150/iw, crop=75:75"', '-f', 'image2', '-q:v', '5', '/a/75.jpg' ]

If I take that, and do .join(' '), I get the command: -ss 00:00:15 -i /a/video.mp4 -vframes 1 -vf "scale=150:ih*150/iw, crop=75:75" -f image2 -q:v 5 /a/75.jpg

When I run ffmpeg with this, all is good.

Any ideas how to format this for spawn arguments?

Thank you!

Upvotes: 0

Views: 264

Answers (1)

aergistal
aergistal

Reputation: 31209

Don't use quotes for vf:

'scale='+size*2+':ih*'+size*2+'/iw,crop='+size+':'+size

Upvotes: 2

Related Questions