编写一个小压缩程序,但我添加的使其成为黑白的选项也会删除声音,我不完全确定这是我的代码有问题还是过滤器没有保留声音文件。else 语句是问题所在。我只是想知道让它工作的唯一方法是在最后重新组合视频的音频文件,这可能会使输出文件超过压缩目标。帮助表示赞赏。
if noSound.get() == 0 and noColour.get() == 0:
ffmpeg.output(i, videoFileName,
**{'c:v': 'libx264', 'b:v': videoBitrate, 'pass': 2, 'c:a': 'aac', 'b:a': audioBitrate, 'f' :'mp4', }
).overwrite_output().run()
print('not selected')
elif noSound.get() == 1 and noColour.get() == 0: ##YOU ARE HERE TRYING TO GET FILTERS TO WORK
ffmpeg.output(i, videoFileName,
**{'c:v': 'libx264', 'b:v': targetTotalBitrate, 'pass': 2,'an':None, 'f' :'mp4'}
).overwrite_output().run()
print('Only Mute Selected')
elif noSound.get() == 1 and noColour.get() == 1: ##YOU ARE HERE TRYING TO GET FILTERS TO WORK
i = ffmpeg.filter(i,'hue', s='0')
ffmpeg.output(i, videoFileName,
**{'c:v': 'libx264', 'b:v': targetTotalBitrate, 'pass': 2,'an':None, 'f' :'mp4'}
).overwrite_output().run()
print('Only Both Selected')
else:
i = ffmpeg.filter_(i,'hue', s='0')
ffmpeg.output(i, videoFileName,
**{'c:v': 'libx264', 'b:v': videoBitrate, 'pass': 2, 'c:a': 'aac', 'b:a': audioBitrate, 'f' :'mp4', }
).overwrite_output().run()
print('Only Greyscale Selected')