Double quotes coming out in golang exec

I need to run the following command:

ffmpeg -i input.jpg -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'" output_320x240_boxed.png

so i do:

cmd = exec.Command("ffmpeg", "-i", "input.jpg", "-vf", "scale=\"'if(gt(a,4/3),640,-1)':'if(gt(a,4/3),-1,300)'\"", "output_320x240_boxed.png")

it does not work with the following error:

Error when evaluating the expression 'if(gt(a,4/3),-1,300)"'.
Maybe the expression for out_w:'"if(gt(a,4/3),640,-1)' or for out_h:'if(gt(a,4/3),-1,300)"' is self-referencing.

The command works when executed on the command line. Why is this happening and how can I avoid these double quotes to prevent this error?

+4
source share
1 answer

When you execute a given command line ffmpeg, your shell parses it as a set of command line arguments, which are essentially:

{
    "ffmpeg",
    "-i",
    "input.jpg",
    "-vf",
    "scale='if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'",
    "output_320x240_boxed.png",
}

scale=..., , . Go, , .

+8

All Articles