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