Ffmpeg by subprocess.Popen: Setting volume by filter doesn't work

Hi there!
I’m converting some videos by use of ffmpeg and subprocess.Popen. Everything is working fine but setting the volume does not. My code:

                # ffmpegPath is defined above
                startArray = [
                    ffmpegPath,
                    '-y', '-i', path
                ]
                try:
                    # Load player info from file, path is defined above:
                    with open(pathPlayerInfo) as f:
                        playerInfo = json.load(f)
                        print(playerInfo)
                        try:
                            volume = int(playerInfo['volume'])/100
                            startArray.append(f'-filter:a \"volume={volume}\"')
                            # the following doesn't work either:
                            # startArray.append('-filter:a')
                            # startArray.append(f'"volume={volume}"')
                            print(f'Set volume {volume}')
                        except:
                            pass
                        pass
                except:
                    pass
                startArray.append(dstPath)
                print(startArray)
                subprocess.Popen(startArray).wait()

I tried two versions of handing over the filter.

The resulting startArray:

['ffmpeg.exe', '-y', '-i', "input.mp4", '-ss', '00:00:53.00', '-filter:a "volume=0.8"', '-o', 'output.mp3']

I get the following error:

[mp3 @ 0000014f6725c140] Invalid stream specifier: a “volume=0.8”.

When I execute the corresponding instruction from the command line it’s working without issues:

C:"ffmpeg.exe" -y -i "input.mp4" -ss 00:00:53.00 -filter:a "volume=0.8" "output.mp3"

(paths were shortened for clarity)

Any help is appreciated.

Best regards, Ulrich

You must not put the double-quotes in the startArrey, they are only needed for commands line run from a shell.

I think this will work once you remove the double quotes.

startArray.append(f'volume={volume}')

Indeed, this way it’s working. Many thanks for this hint, you saved my day.